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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
             Blocks|                            |123615
   Last reconfirmed|                            |2026-06-01
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
The ICE is during mangling of the anonymous union member.
#include <meta>
struct A { union {}; };
constexpr auto ctx = std::meta::access_context::unchecked ();
template <auto I>
int a = 42;
int b = a <members_of (^^A, ctx)[1]>;

write_unqualified_name has:
  if (DECL_NAME (decl) == NULL_TREE
      && ANON_AGGR_TYPE_P (TREE_TYPE (decl)))
    decl = anon_aggr_naming_decl (TREE_TYPE (decl));
  else if (DECL_NAME (decl) == NULL_TREE)
    {
      found = true;
      gcc_assert (DECL_ASSEMBLER_NAME_SET_P (decl));
      write_source_name (DECL_ASSEMBLER_NAME (decl));
    }

Now, anon_aggr_naming_decl refers to the itanium mangling:
/* "For the purposes of mangling, the name of an anonymous union is considered
   to be the name of the first named data member found by a pre-order,
   depth-first, declaration-order walk of the data members of the anonymous
   union. If there is no such data member (i.e., if all of the data members in
   the union are unnamed), then there is no way for a program to refer to the
   anonymous union, and there is therefore no need to mangle its name."  */

which comes from
https://itanium-cxx-abi.github.io/cxx-abi/abi.html#mangling.anonymous
Except this is unfortunately no longer true, with reflection there is a way for
a program to refer to the anonymous union and so we need to come up with a way
to mangle it.


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123615
[Bug 123615] (c++-reflection) - [meta-bug] reflection issue

Reply via email to