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

--- Comment #5 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Jason Merrill <[email protected]>:

https://gcc.gnu.org/g:92a1d876b20426ebd240ad9bd65d9bce2705611d

commit r16-8693-g92a1d876b20426ebd240ad9bd65d9bce2705611d
Author: Egas Ribeiro <[email protected]>
Date:   Thu Jan 1 03:41:14 2026 +0000

    c++: fix constexpr union with empty member [PR123346]

    r14-2820 changed cxx_eval_bare_aggregate to set no_slot based on whether
    new_ctx.ctor is NULL_TREE, to handle empty subobject elision. However
    this incorrectly omits entries for empty union members, which later need
    the entry to exist.
    This caused valid code to be rejected as non-constant after gcc 13.3,
    and in trunk caused an ICE when the diagnostic code tries to print a
    CONSTRUCTOR with a null value.

            PR c++/123346

    gcc/cp/ChangeLog:

            * constexpr.cc (init_subob_ctx): Do initialize new_ctx.ctor
            for an empty union member.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp2a/constexpr-union10.C: New test.

    Signed-off-by: Egas Ribeiro <[email protected]>
    Co-authored-by: Jason Merrill <[email protected]>

Reply via email to