From: Jason Merrill Date: Fri, 5 Jul 2002 22:10:25 +0000 (-0400) Subject: cvt.c (cp_convert_to_pointer): Call force_fit_type for null pointers. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=212e17fd89735946ac3640225958d50bc4392979;p=gcc.git cvt.c (cp_convert_to_pointer): Call force_fit_type for null pointers. * cvt.c (cp_convert_to_pointer): Call force_fit_type for null pointers. From-SVN: r55272 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index ab5c1449a8e..1c4b06d9943 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,8 @@ 2002-07-05 Jason Merrill + * 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. diff --git a/gcc/cp/cvt.c b/gcc/cp/cvt.c index 0c43fc3609c..bd42b42c4ed 100644 --- a/gcc/cp/cvt.c +++ b/gcc/cp/cvt.c @@ -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 index 00000000000..ed6d8757441 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/ptrmem3.C @@ -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); +}