boostorg / boostorg/optional

Boost. 1.91.0 regression: optional<bool> copy constructor broken

Open
#146 1 comment 4 reactions 0 assignees View on GitHub
bug
Dominant language
C++
Stars
60
Forks
75
PR merge metrics
No merged PRs in 30d

Description

Consider the following code:
```
const boost::optional constValue;
assert(!constValue.has_value()); // succeeds
boost::optional mutableValue(constValue);
assert(!mutableValue.has_value()); // succeeds
boost::optional mutableCopy(mutableValue);
assert(!mutableCopy.has_value()); // fails
```

The reason is that the wrong constructor is taken for `boost::optional(boost::optional&)`:
https://github.com/boostorg/optional/blob/88e2378c8a9a45d4617d9386619677038b392ff1/include/boost/optional/detail/union_optional.hpp#L391
instead of
https://github.com/boostorg/optional/blob/88e2378c8a9a45d4617d9386619677038b392ff1/include/boost/optional/detail/union_optional.hpp#L293.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.