https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112571
--- Comment #6 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-13 branch has been updated by Joseph Myers <js...@gcc.gnu.org>: https://gcc.gnu.org/g:f2af129b68bc6b20f79a9a44b28c96650baa702c commit r13-8495-gf2af129b68bc6b20f79a9a44b28c96650baa702c Author: Joseph Myers <josmy...@redhat.com> Date: Wed Jan 31 21:39:53 2024 +0000 c: Fix ICE for nested enum redefinitions with/without fixed underlying type [PR112571] Bug 112571 reports an ICE-on-invalid for cases where an enum is defined, without a fixed underlying type, inside the enum type specifier for a definition of that same enum with a fixed underlying type. The ultimate cause is attempting to access ENUM_UNDERLYING_TYPE in a case where it is NULL. Avoid this by clearing ENUM_FIXED_UNDERLYING_TYPE_P in thie case of inconsistent definitions. Bootstrapped wth no regressions for x86_64-pc-linux-gnu. (Note: for this GCC 13 branch backport, the tests were changed to use -std=c2x not -std=c23, and c23-enum-9.c was changed to expect different diagnostics because GCC 13 branch doesn't have the C23 tag compatibility support for redefinitions of tagged types and enumerators.) PR c/112571 gcc/c/ * c-decl.cc (start_enum): Clear ENUM_FIXED_UNDERLYING_TYPE_P when defining without a fixed underlying type an enumeration previously declared with a fixed underlying type. gcc/testsuite/ * gcc.dg/c23-enum-9.c, gcc.dg/c23-enum-10.c: New tests. (cherry picked from commit d22d1a9346f27db41459738c6eb404f8f0956e6f)