[Bug c++/94066] [8/9/10 Regression] ICE (starting/ending union member lifetime) in cxx_eval_bare_aggregate, at cp/constexpr.c:3790 since r6-7592

ppalka at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Sun Mar 8 16:54:23 GMT 2020


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94066

--- Comment #5 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Also if we add an explicitly defaulted constructor "U() = default;" to U in the
original test case, then

using GCC 9 /w -std=c++17 we get:
94066.C:16:25:   in ‘constexpr’ expansion of ‘foo((&*this))’
94066.C:12:9: error: change of the active member of a union from ‘U::a’ to
‘U::y’
   12 |   up->y = 11;
      |   ~~~~~~^~~~
94066.C:16: confused by earlier errors, bailing out


using GCC 9 /w -std=c++2a compiles successfully, and we think U::y is the
active member, but static_assert(u.y == 11) fails with "error: ‘(((int)A{42})
== 11)’ is not a constant expression"


using GCC trunk /w -std=c++17 we get an active-member diagnostic as in GCC 9,
and the same ICE as in #c1


using GCC trunk /w -std=c++2a we get same behavior as in GCC 9 /w -std=c++2a


More information about the Gcc-bugs mailing list