<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/59854>59854</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
explicitly noexcept destructor incorrectly not constexpr
</td>
</tr>
<tr>
<th>Labels</th>
<td>
bug,
clang:frontend
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
CaseyCarter
</td>
</tr>
</table>
<pre>
This well-formed C++20 TU:
```c++
#include <vector>
template <class E>
struct expected {
constexpr explicit expected(std::initializer_list<int> il) : unex(il) {}
constexpr ~expected()
#ifndef MEOW
noexcept
#endif
{ unex.~E(); }
constexpr explicit operator bool() const { return true; }
union { E unex; };
};
struct Data {
std::vector<int> vec_;
constexpr Data(std::initializer_list<int> il) : vec_(il) {}
};
static_assert(expected<Data>({1, 2, 3}));
```
fails to compile if `MEOW` isn't defined (https://godbolt.org/z/qx1nEzvzW):
```
<source>:20:15: error: static assertion expression is not an integral constant expression
static_assert(expected<Data>({1, 2, 3}));
^~~~~~~~~~~~~~~~~~~~~~~~~
<source>:20:15: note: subexpression not valid in a constant expression
<source>:20:15: note: in call to '&expected<Data>({1, 2, 3})->~expected()'
1 error generated.
```
The repro is admittedly not library-free, but it does reproduce with all of libc++, libstdc++, and MSVCSTL - and not with GCC or MSVC - so I'm reasonably confident the bug is in the compiler and not the implementation of `vector`.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysVUGP4jgT_TXmUgIFGxI45ABp-PRJO9rD9O4cW45dAa-MzdqVnu4-9G9f2Qk0Yns0u9IiFGK7_Kree3YhYzQHh1iz5ZYtHyayp6MPdSMjvjYyEIZJ6_Vr_Xg0Eb6jtdPOhxNqaBjfMr7lBTz-xsSGFQ-s2LCyGL5qWB1nuTBO2V4jMNE8oyIfmNiNi_lJeDpbSTlAWRkj7K4RkUKvCPDljIpQA6tGXADlXSR8OYe0ao0yH2GMryLpVJnYGGfISGveMD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