cvt.c (cp_convert_to_pointer): Call force_fit_type for null pointers.
authorJason Merrill <jason@redhat.com>
Fri, 5 Jul 2002 22:10:25 +0000 (18:10 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Fri, 5 Jul 2002 22:10:25 +0000 (18:10 -0400)
        * cvt.c (cp_convert_to_pointer): Call force_fit_type for null
        pointers.

From-SVN: r55272

gcc/cp/ChangeLog
gcc/cp/cvt.c
gcc/testsuite/g++.dg/other/ptrmem3.C [new file with mode: 0644]

index ab5c1449a8ee23b374b45dcaf2995d2d0f908ab8..1c4b06d994304ae3895357430fa96fe051cca7a4 100644 (file)
@@ -1,5 +1,8 @@
 2002-07-05  Jason Merrill  <jason@redhat.com>
 
+       * cvt.c (cp_convert_to_pointer): Call force_fit_type for null
+       pointers.
+
        PR optimization/7145
        * tree.c (cp_copy_res_decl_for_inlining): Also copy DECL_INITIAL.
 
index 0c43fc3609c9f422387e3dabe3d4de730d29e5e1..bd42b42c4ed94972700cf985cb1c468a4c5a8d84 100644 (file)
@@ -252,6 +252,8 @@ cp_convert_to_pointer (type, expr, force)
       else
        expr = build_int_2 (0, 0);
       TREE_TYPE (expr) = type;
+      /* Fix up the representation of -1 if appropriate.  */
+      force_fit_type (expr, 0);
       return expr;
     }
 
diff --git a/gcc/testsuite/g++.dg/other/ptrmem3.C b/gcc/testsuite/g++.dg/other/ptrmem3.C
new file mode 100644 (file)
index 0000000..ed6d875
--- /dev/null
@@ -0,0 +1,14 @@
+// Bug: The double cast had an TREE_INT_CST_HIGH of 0, while the single
+// cast had -1, so the comparison failed.
+
+// { dg-do run }
+
+struct A { };
+
+typedef int A::* aip;
+typedef long A::* alp;
+
+int main()
+{
+  return ((aip)(alp)0 != (aip)0);
+}