[libc++] direct-initialized engaged -> disengaged std::optional incorrectly deemed not a constant expression
Open
constexpr
libc++
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
The following snippet is rejected by Clang + libc++ (doesn't seem to be a regression):
```c++
#include
struct B {
constexpr B(int m) : m(m) { }
constexpr ~B() { }
int m;
};
static_assert(!std::is_trivially_destructible_v);
struct C : std::optional {
constexpr C() : std::optional(1) { this->reset(); }
};
constexpr C c;
```
```
:14:13: error: constexpr variable 'c' must be initialized by a constant expression
14 | constexpr C c;
| ^
:14:13: note: subobject '__val_' is not initialized
```
https://godbolt.org/z/rnncqhcY6
Contributor guide
Assessment
This issue has not been assessed yet.