https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91222

--- Comment #2 from Jan Hubicka <hubicka at gcc dot gnu.org> ---
This patch fixes the ICE
Index: ipa-devirt.c
===================================================================
--- ipa-devirt.c        (revision 273865)
+++ ipa-devirt.c        (working copy)
@@ -1003,7 +1003,7 @@ warn_types_mismatch (tree t1, tree t2, l
        n2 = DECL_NAME (n2);
       /* Most of the time, the type names will match, do not be unnecesarily
          verbose.  */
-      if (IDENTIFIER_POINTER (n1) != IDENTIFIER_POINTER (n2))
+      if (n1 != n2)
         inform (loc_t1,
                "type %qT defined in anonymous namespace cannot match "
                "type %qT across the translation unit boundary",
however the warnings output are:
2.ii:62:3: warning: ‘ml_bssnrest_’ violates the C++ One Definition Rule [-Wodr]
   62 | } ml_bssnrest_;
      |   ^
1.ii:2:8: note: type ‘struct <anon>’ defined in anonymous namespace cannot
match across the translation unit boundary
    2 | struct {
      |        ^
2.ii:2:15: note: the incompatible type defined in another translation unit
    2 | extern struct {
      |               ^
1.ii:62:3: note: ‘ml_bssnrest_’ was previously declared here
   62 | } ml_bssnrest_;
      |   ^

Now I wonder why C++ FE makes the struct anonymous namespace when it is
declared with extern "C".
I have checked that type_in_anonymous_namespace_p(prevailing_type) returns true
because mangled name is <anon> which comes from C++ FE.

I will check in the patch to avoid ICE. Jason, can you please look if it is
correct to consider these types anonymous?

Reply via email to