https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97195
David Stone <david at doublewise dot net> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |david at doublewise dot net
--- Comment #1 from David Stone <david at doublewise dot net> ---
This is actually a broader bug in construct_at, unrelated to unions:
```
#include <memory>
constexpr bool test() {
int a = 5;
std::construct_at(
&a,
-1
);
return true;
}
constexpr bool b = test();
```
is also rejected. See it live: https://godbolt.org/z/KWK8n1
The real problem here appears to be that std::construct_at is not a constant
expression for values with non-constant addresses. The following code, for
example, is accepted:
```
#include <memory>
struct S {
constexpr S() {
std::construct_at(
&m,
-1
);
}
int m;
};
constexpr S s;
```
See it live: https://godbolt.org/z/Wdx9Kx