https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105491
Patrick Palka <ppalka at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |ASSIGNED Assignee|unassigned at gcc dot gnu.org |ppalka at gcc dot gnu.org --- Comment #7 from Patrick Palka <ppalka at gcc dot gnu.org> --- This seems to fix it: --- a/gcc/cp/constexpr.cc +++ b/gcc/cp/constexpr.cc @@ -1886,7 +1886,8 @@ cxx_eval_internal_function (const constexpr_ctx *ctx, tree t, static void clear_no_implicit_zero (tree ctor) { - if (CONSTRUCTOR_NO_CLEARING (ctor)) + if (CONSTRUCTOR_NO_CLEARING (ctor) + || TREE_CODE (TREE_TYPE (ctor)) == UNION_TYPE) { CONSTRUCTOR_NO_CLEARING (ctor) = false; for (auto &e: CONSTRUCTOR_ELTS (ctor)) When recursively clearing CONSTRUCTOR_NO_CLEARING, it could be the case that a union's initializer has CONSTRUCTOR_NO_CLEARING already cleared but its sub-aggregates don't, because for unions CONSTRUCTOR_NO_CLEARING is overloaded to also track whether we're in the process of initializing a union member.