diff options
Diffstat (limited to 'gcc')
| -rw-r--r-- | gcc/cp/ChangeLog | 3 | ||||
| -rw-r--r-- | gcc/cp/cvt.c | 2 | ||||
| -rw-r--r-- | gcc/testsuite/g++.dg/other/ptrmem3.C | 14 |
3 files changed, 19 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index ab5c144..1c4b06d 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -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. diff --git a/gcc/cp/cvt.c b/gcc/cp/cvt.c index 0c43fc3..bd42b42 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 0000000..ed6d875 --- /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); +} |
