https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97665
Bug ID: 97665
Summary: constexpr union array member incorrectly rejected as
non-constexpr
Product: gcc
Version: 11.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: ldalessandro at gmail dot com
Target Milestone: ---
GCC currently rejects the following code snippet, where it infers the constexpr
definition of V as non-constexpr. The monostate member provides a temporary
workaround.
https://godbolt.org/z/Ph1n1P
```
struct Foo {
constexpr Foo() {}
};
union U {
// struct {} monostate = {};
Foo foo;
constexpr U() {}
};
struct V {
U storage[1];
};
constexpr V v;
```