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

--- Comment #7 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-13 branch has been updated by Marek Polacek
<mpola...@gcc.gnu.org>:

https://gcc.gnu.org/g:988c0b796721d6e8be6a54abb48b695dae972dcf

commit r13-9345-g988c0b796721d6e8be6a54abb48b695dae972dcf
Author: Marek Polacek <pola...@redhat.com>
Date:   Mon Nov 25 09:45:13 2024 -0500

    c++: ICE with nested anonymous union [PR117153]

    In a template, for

      union {
        union {
          T d;
        };
      };

    build_anon_union_vars crates a malformed COMPONENT_REF: we have no
    DECL_NAME for the nested anon union so we create something like "object.".
    Most of the front end doesn't seem to care, but if such a tree gets to
    potential_constant_expression, it can cause a crash.

    We can use FIELD directly for the COMPONENT_REF's member.  tsubst_stmt
    should build up a proper one in:

        if (VAR_P (decl) && !DECL_NAME (decl)
            && ANON_AGGR_TYPE_P (TREE_TYPE (decl)))
          /* Anonymous aggregates are a special case.  */
          finish_anon_union (decl);

            PR c++/117153

    gcc/cp/ChangeLog:

            * decl2.cc (build_anon_union_vars): Use FIELD for the second
operand
            of a COMPONENT_REF.

    gcc/testsuite/ChangeLog:

            * g++.dg/other/anon-union6.C: New test.
            * g++.dg/other/anon-union7.C: New test.

    Reviewed-by: Jason Merrill <ja...@redhat.com>
    (cherry picked from commit 10850f92b2a618ef1b1ad399530943ef4847823d)

Reply via email to