https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126922
--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
A fix to avoid ICEing could be e.g.
--- gcc/cp/mangle.cc.jj 2026-08-18 08:47:22.024793339 +0200
+++ gcc/cp/mangle.cc 2026-08-18 17:36:58.267273806 +0200
@@ -3888,8 +3888,14 @@ write_expression (tree expr)
if (field == ce->index)
break;
if (abi_check (21))
- write_expression (build_zero_cst
- (TREE_TYPE (field)));
+ {
+ tree type = TREE_TYPE (field), expr;
+ if (REFLECTION_TYPE_P (type))
+ expr = get_null_reflection ();
+ else
+ expr = build_zero_cst (type);
+ write_expression (expr);
+ }
field = DECL_CHAIN (field);
}
}
but I'm not sure it is right.
If I have
struct A {
int a, b;
};
struct B {
A c;
};
template <auto C>
void
foo ()
{
}
int
main ()
{
foo <A { .a = {}, .b = {} }> ();
foo <A { .a = {} }> ();
foo <A { .b = {} }> ();
foo <B { .c = {} }> ();
}
then the first 3 calls are mangled _Z3fooITnDaXtl1AEEEvv and the last one
_Z3fooITnDaXtl1BEEEvv.
Similarly for
struct A {
int A::*a, A::*b;
};
struct B {
A c;
};
template <auto C>
void
foo ()
{
}
int
main ()
{
foo <A { .a = {}, .b = {} }> ();
foo <A { .a = {} }> ();
foo <A { .b = {} }> ();
foo <B { .c = {} }> ();
}
3 times _Z3fooITnDaXtl1AEEEvv and once _Z3fooITnDaXtl1BEEEvv.
But
struct A {
decltype (^^::) a, b;
};
struct B {
A c;
};
template <auto C>
void
foo ()
{
}
int
main ()
{
foo <A { .a = {}, .b = {} }> ();
foo <A { .a = {} }> ();
foo <A { .b = {} }> ();
foo <B { .c = {} }> ();
}
gets _Z3fooITnDaXtl1ALDmnuELDmnuEEEEvv for the first and third call and
_Z3fooITnDaXtl1ALDmnuEEEEvv for the second call and _Z3fooITnDaXtl1BEEEvv for
the last call. I think all the first 3 cases have the same value and so need
to be call to the same function with the same mangling.