Bug 49309 - [4.6 Regression] ICE with -fmudflap: verify_stmts failed: type mismatch in pointer plus expression
Summary: [4.6 Regression] ICE with -fmudflap: verify_stmts failed: type mismatch in po...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 4.7.0
: P2 normal
Target Milestone: 4.6.2
Assignee: Andrew Pinski
URL: http://gcc.gnu.org/ml/gcc-patches/201...
Keywords: ice-on-valid-code, patch
Depends on:
Blocks:
 
Reported: 2011-06-07 07:17 UTC by Volker Reichelt
Modified: 2011-07-25 15:28 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work: 4.5.3
Known to fail: 4.6.0
Last reconfirmed: 2011-07-12 21:06:29


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Volker Reichelt 2011-06-07 07:17:11 UTC
The following testcase compiled with "-fmudflap -O" triggers an ICE

=========================================
struct A
{
  int i;

  A();
  A(const A&);
};

inline void foo(A a) { a = A(); }

void bar() { foo(A()); }
=========================================

bug.cc: In function 'void bar()':
bug.cc:11:6: error: type mismatch in pointer plus expression
struct A & restrict

struct A *

long unsigned int

D.1282_15 = &D.1260 + 0;

bug.cc:11:6: internal compiler error: verify_gimple failed
Please submit a full bug report, [etc.]
Comment 1 Jakub Jelinek 2011-06-27 12:33:15 UTC
GCC 4.6.1 is being released.
Comment 2 Andrew Pinski 2011-07-12 21:06:29 UTC
Simple fix:
Index: tree-mudflap.c
===================================================================
--- tree-mudflap.c	(revision 62112)
+++ 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, 1)),
 		     TREE_OPERAND (t, 0),
 		     fold_convert (sizetype, TREE_OPERAND (t, 1)));
       base = addr;
Comment 3 Richard Biener 2011-07-12 21:18:50 UTC
Hm, I'd say rather

-      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)),
Comment 4 Andrew Pinski 2011-07-14 20:23:39 UTC
Author: pinskia
Date: Thu Jul 14 20:23:36 2011
New Revision: 176281

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=176281
Log:
2011-07-14  Andrew Pinski  <pinskia@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-14  Andrew Pinski  <pinskia@gmail.com>

	PR tree-opt/49309
	* g++.dg/torture/pr49309.C: New testcase.


Added:
    trunk/gcc/testsuite/g++.dg/torture/pr49309.C
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-mudflap.c
Comment 5 Andrew Pinski 2011-07-14 20:26:46 UTC
Fixed on the trunk will apply to the 4.6 branch soon.
Comment 6 Andrew Pinski 2011-07-14 20:55:42 UTC
Author: pinskia
Date: Thu Jul 14 20:55:38 2011
New Revision: 176282

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=176282
Log:
2011-07-14  Andrew Pinski  <pinskia@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-14  Andrew Pinski  <pinskia@gmail.com>

	PR tree-opt/49309
	* g++.dg/torture/pr49309.C: New testcase.


Added:
    branches/gcc-4_6-branch/gcc/testsuite/g++.dg/torture/pr49309.C
      - copied unchanged from r176281, trunk/gcc/testsuite/g++.dg/torture/pr49309.C
Modified:
    branches/gcc-4_6-branch/gcc/ChangeLog
    branches/gcc-4_6-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_6-branch/gcc/tree-mudflap.c
Comment 7 Andrew Pinski 2011-07-14 20:56:23 UTC
Fixed.
Comment 8 Jakub Jelinek 2011-07-15 19:48:50 UTC
Author: jakub
Date: Fri Jul 15 19:48:46 2011
New Revision: 176327

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=176327
Log:
	PR testsuite/49753
	PR tree-optimization/49309
	* testsuite/libmudflap.c++/pass68-frag.cxx: New test.

	* g++.dg/torture/pr49309.C: Remove.

Added:
    trunk/libmudflap/testsuite/libmudflap.c++/pass68-frag.cxx
Removed:
    trunk/gcc/testsuite/g++.dg/torture/pr49309.C
Modified:
    trunk/gcc/testsuite/ChangeLog
    trunk/libmudflap/ChangeLog
Comment 9 Jakub Jelinek 2011-07-15 19:54:01 UTC
Author: jakub
Date: Fri Jul 15 19:53:58 2011
New Revision: 176328

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=176328
Log:
	PR testsuite/49753
	PR tree-optimization/49309
	* testsuite/libmudflap.c++/pass68-frag.cxx: New test.

	* g++.dg/torture/pr49309.C: Remove.

Added:
    branches/gcc-4_6-branch/libmudflap/testsuite/libmudflap.c++/pass68-frag.cxx
Removed:
    branches/gcc-4_6-branch/gcc/testsuite/g++.dg/torture/pr49309.C
Modified:
    branches/gcc-4_6-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_6-branch/libmudflap/ChangeLog
Comment 10 Rainer Orth 2011-07-25 15:25:37 UTC
Author: ro
Date: Mon Jul 25 15:25:32 2011
New Revision: 176752

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=176752
Log:
	gcc/testsuite:
	PR testsuite/49753
	* g++.dg/torture/pr49309.C: Add -fpreprocessed to dg-options.

	Revert:
	2011-07-15  Jakub Jelinek  <jakub@redhat.com>

	PR testsuite/49753
	* g++.dg/torture/pr49309.C: Remove.

	libmudflap:
	Revert:
	2011-07-15  Jakub Jelinek  <jakub@redhat.com>

	PR testsuite/49753
	PR tree-optimization/49309
	* testsuite/libmudflap.c++/pass68-frag.cxx: New test.

Added:
    trunk/gcc/testsuite/g++.dg/torture/pr49309.C
      - copied, changed from r176751, trunk/libmudflap/testsuite/libmudflap.c++/pass68-frag.cxx
Removed:
    trunk/libmudflap/testsuite/libmudflap.c++/pass68-frag.cxx
Modified:
    trunk/gcc/testsuite/ChangeLog
    trunk/libmudflap/ChangeLog
Comment 11 Rainer Orth 2011-07-25 15:28:30 UTC
Author: ro
Date: Mon Jul 25 15:28:27 2011
New Revision: 176753

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=176753
Log:
	gcc/testsuite:
	PR testsuite/49753
	* g++.dg/torture/pr49309.C: Add -fpreprocessed to dg-options.

	Revert:
	2011-07-15  Jakub Jelinek  <jakub@redhat.com>

	PR testsuite/49753
	* g++.dg/torture/pr49309.C: Remove.

	libmudflap:
	Revert:
	2011-07-15  Jakub Jelinek  <jakub@redhat.com>

	PR testsuite/49753
	PR tree-optimization/49309
	* testsuite/libmudflap.c++/pass68-frag.cxx: New test.

Added:
    branches/gcc-4_6-branch/gcc/testsuite/g++.dg/torture/pr49309.C
      - copied, changed from r176752, branches/gcc-4_6-branch/libmudflap/testsuite/libmudflap.c++/pass68-frag.cxx
Removed:
    branches/gcc-4_6-branch/libmudflap/testsuite/libmudflap.c++/pass68-frag.cxx
Modified:
    branches/gcc-4_6-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_6-branch/libmudflap/ChangeLog