[PATCH] types_compatible_p mess 2/3 (C++)

Paolo Bonzini bonzini@gnu.org
Thu Mar 6 13:36:00 GMT 2008


It seems to me that lang_hooks.types_compatible_p should never be called
with reference types.  I tested this with the testcase

extern int printf (const char *, ...);
int f(int &x)
{
   printf ("%p", &x);
}

Ok?

Paolo

Index: cp-objcp-common.c
===================================================================
--- cp-objcp-common.c   (revision 131960)
+++ cp-objcp-common.c   (working copy)
@@ -188,15 +188,6 @@ cxx_types_compatible_p (tree x, tree y)
    if (same_type_ignoring_top_level_qualifiers_p (x, y))
      return 1;

-  /* Once we get to the middle-end, references and pointers are
-     interchangeable.  FIXME should we try to replace all references with
-     pointers?  */
-  if (POINTER_TYPE_P (x) && POINTER_TYPE_P (y)
-      && TYPE_MODE (x) == TYPE_MODE (y)
-      && TYPE_REF_CAN_ALIAS_ALL (x) == TYPE_REF_CAN_ALIAS_ALL (y)
-      && same_type_p (TREE_TYPE (x), TREE_TYPE (y)))
-    return 1;
-
    return 0;
  }





More information about the Gcc-patches mailing list