https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122905
--- Comment #10 from Jakub Jelinek <jakub at gcc dot gnu.org> --- So, the reason for the ODR failure is different mangling of the anonymous union. free_lang_data calls decl_assembler_name on the anonymous union in mys, and that eventually calls cp/mangle.cc (nested_anon_class_index). And that function increments index for every TYPE_UNNAMED_P before the type it is looking for in TYPE_FIELDS. So, with r16-3233 for C++17 it counts even the unnamed enumeral type in mys, while for C++20 it doesn't. I think safest would be to simply never return true in enum_with_enumerator_for_linkage_p unless && TYPE_NAMESPACE_SCOPE_P (type).
