https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124241
--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Tried
--- gcc/cp/reflect.cc.jj 2026-03-18 06:36:10.823910808 +0100
+++ gcc/cp/reflect.cc 2026-03-23 16:27:46.902521589 +0100
@@ -6439,6 +6439,13 @@ eval_is_accessible (location_t loc, cons
else
{
tree o = TYPE_P (r) ? TYPE_NAME (r) : r;
+ /* Both anon union and struct only allow public members and
+ accessible_p can ICE with anon aggr FIELD_DECLs. */
+ while (TREE_CODE (o) == FIELD_DECL
+ && ANON_AGGR_TYPE_P (DECL_CONTEXT (o))
+ && !same_type_p (TYPE_MAIN_VARIANT (designating_class),
+ DECL_CONTEXT (o)))
+ o = ANON_AGGR_TYPE_FIELD (DECL_CONTEXT (o));
if (accessible_p (TYPE_BINFO (designating_class), o,
/*consider_local_p=*/true))
ret = boolean_true_node;
but that is not it. The problem is probably related to designating_class being
here the anon union type.