https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97195
Bug ID: 97195 Summary: construct_at on a union member is not a constant expression Product: gcc Version: 10.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: barry.revzin at gmail dot com Target Milestone: --- In trying to test adding more constexpr support to std::optional: #include <bits/stl_construct.h> union S { int i; }; constexpr int f() { S s; std::construct_at(&s.i, 0); return 0; } constexpr int z = f(); gcc rejects with: <source>:13:20: in 'constexpr' expansion of 'f()' <source>:9:22: in 'constexpr' expansion of 'std::construct_at<int, int>((& s.S::i), 0)' <source>:13:21: error: '(void*)(& s.S::i)' is not a constant expression 13 | constexpr int z = f(); | ^ But this should be fine.