https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65072
--- Comment #7 from Marek Polacek <mpolacek at gcc dot gnu.org> --- Here, we SEGV in build_class_member_access_expr, called recursively: tree anonymous_union; anonymous_union = lookup_anon_field (TREE_TYPE (object), DECL_CONTEXT (member)); object = build_class_member_access_expr (object, anonymous_union, [...] anonymous_union is NULL and build_class_member_access_expr is not prepared to handle that. anonymous_union is NULL because lookup_anon_field returned NULL: it tried to look for a "struct ._0" type in "const struct C" -- and found nothing. That is because "const struct C" doesn't have any fields! But if I change the testcase so that C is not const, it passes, because "struct C" then has fields and lookup_anon_field is able to find a FIELD_DECL. So the question is why "const struct C" doesn't have any fields. I couldn't figure that out yet :(.