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

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

https://gcc.gnu.org/g:660fa7fd354b71f864f67e5e1966a6e62f8a2c3b

commit r14-12605-g660fa7fd354b71f864f67e5e1966a6e62f8a2c3b
Author: Egas Ribeiro <[email protected]>
Date:   Thu May 14 12:20:23 2026 -0400

    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]>
    (cherry picked from commit 92a1d876b20426ebd240ad9bd65d9bce2705611d)

Reply via email to