Hi, The problem here is that the type of the POINTER_PLUS_EXPR is incorrect and also the non folded version leaks to the IR. This patch fixes those two problems and fixes the ICE.
OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions. Thanks, Andrew Pinski 2011-07-13 Andrew Pinski <pins...@gmail.com> PR tree-opt/49309 * tree-mudflap.c (mf_xform_derefs_1 <case MEM_REF>): Use fold_build2_loc instead of build2. Use the correct type for the new tree. 2011-07-13 Andrew Pinski <pins...@gmail.com> PR tree-opt/49309 * g++.dg/torture/pr49309.C: New testcase.
Index: ChangeLog =================================================================== --- ChangeLog (revision 176249) +++ ChangeLog (working copy) @@ -1,3 +1,10 @@ +2011-07-13 Andrew Pinski <pins...@gmail.com> + + PR tree-opt/49309 + * tree-mudflap.c (mf_xform_derefs_1 <case MEM_REF>): + Use fold_build2_loc instead of build2. + Use the correct type for the new tree. + 2011-07-13 Ulrich Weigand <ulrich.weig...@de.ibm.com> * config/spu/spu.c (spu_init_libfuncs): Install __clrsbdi2. Index: testsuite/ChangeLog =================================================================== --- testsuite/ChangeLog (revision 176249) +++ testsuite/ChangeLog (working copy) @@ -1,3 +1,8 @@ +2011-07-13 Andrew Pinski <pins...@gmail.com> + + PR tree-opt/49309 + * g++.dg/torture/pr49309.C: New testcase. + 2011-07-13 Janne Blomqvist <j...@gcc.gnu.org> PR libfortran/49296 Index: testsuite/g++.dg/torture/pr49309.C =================================================================== --- testsuite/g++.dg/torture/pr49309.C (revision 0) +++ testsuite/g++.dg/torture/pr49309.C (revision 0) @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-fmudflap" } */ +struct A +{ + int i; + + A(); + A(const A&); +}; + +inline void foo(A a) { a = A(); } + +void bar() { foo(A()); } + Index: tree-mudflap.c =================================================================== --- tree-mudflap.c (revision 176218) +++ tree-mudflap.c (working copy) @@ -869,7 +869,7 @@ mf_xform_derefs_1 (gimple_stmt_iterator break; case MEM_REF: - addr = build2 (POINTER_PLUS_EXPR, TREE_TYPE (TREE_OPERAND (t, 1)), + addr = fold_build2_loc (location, POINTER_PLUS_EXPR, TREE_TYPE (TREE_OPERAND (t, 0)), TREE_OPERAND (t, 0), fold_convert (sizetype, TREE_OPERAND (t, 1))); base = addr;