Bug 22013 - [4.0 Regression] ICE in gimple_add_tmp_var, at gimplify.c:535
Summary: [4.0 Regression] ICE in gimple_add_tmp_var, at gimplify.c:535
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 4.1.0
: P2 normal
Target Milestone: 4.0.2
Assignee: Joseph S. Myers
URL:
Keywords: ice-on-valid-code
: 22050 (view as bug list)
Depends on:
Blocks: 22098
  Show dependency treegraph
 
Reported: 2005-06-11 06:10 UTC by marcus
Modified: 2005-07-08 14:48 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work: 3.4.4 4.1.0
Known to fail: 4.0.0
Last reconfirmed: 2005-06-30 15:00:16


Attachments
dialog.i (164 bytes, text/plain)
2005-06-11 06:11 UTC, marcus
Details

Note You need to log in before you can comment on or make changes to this bug.
Description marcus 2005-06-11 06:10:32 UTC
Following testcase extracted from WINE crashes in gimple_add_tmp_var, at 
gimplify.c:535 
 
/home/marcus/projects/gcc/BIN/bin/gcc -O2 -c dialog.i  
dialog.i: In function 'f': 
dialog.i:8: internal compiler error: in gimple_add_tmp_var, at gimplify.c:535 
Please submit a full bug report, 
with preprocessed source if appropriate. 
See <URL:http://gcc.gnu.org/bugs.html> for instructions. 
 
gcc version 4.1.0 20050610 (experimental)
Comment 1 marcus 2005-06-11 06:11:00 UTC
Created attachment 9067 [details]
dialog.i

gcc -c -O2 dialog.i
Comment 2 Steven Bosscher 2005-06-11 09:11:53 UTC
Problem seems to be that the C front end assumes something without 
a DECL_NAME is not yet in the unexpanded variables list.  Don't ask 
me why :-/ 
 
Hack: 
 
Index: c-gimplify.c 
=================================================================== 
RCS file: /cvs/gcc/gcc/gcc/c-gimplify.c,v 
retrieving revision 2.30 
diff -u -3 -p -r2.30 c-gimplify.c 
--- c-gimplify.c        1 Jun 2005 02:50:51 -0000       2.30 
+++ c-gimplify.c        11 Jun 2005 09:10:51 -0000 
@@ -185,9 +185,11 @@ gimplify_compound_literal_expr (tree *ex 
   tree decl = DECL_EXPR_DECL (decl_s); 
 
   /* This decl isn't mentioned in the enclosing block, so add it to the 
-     list of temps.  FIXME it seems a bit of a kludge to say that 
-     anonymous artificial vars aren't pushed, but everything else is.  */ 
-  if (DECL_NAME (decl) == NULL_TREE) 
+     list of temps if it is not already in that list. 
+     FIXME it seems a bit of a kludge to say that anonymous artificial 
+     vars aren't pushed, but everything else is.  */ 
+  if (DECL_NAME (decl) == NULL_TREE 
+      && !DECL_SEEN_IN_BIND_EXPR_P (decl)) 
     gimple_add_tmp_var (decl); 
 
   gimplify_and_add (decl_s, pre_p); 
 
Comment 3 Andrew Pinski 2005-06-11 14:58:56 UTC
Confirmed.
Comment 4 Andrew Pinski 2005-06-13 15:15:39 UTC
*** Bug 22050 has been marked as a duplicate of this bug. ***
Comment 5 Joseph S. Myers 2005-06-30 15:00:16 UTC
Testing a patch for bugs 22013 and 22098.
Comment 6 GCC Commits 2005-07-05 17:50:38 UTC
Subject: Bug 22013

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	jsm28@gcc.gnu.org	2005-07-05 17:50:24

Modified files:
	gcc            : ChangeLog c-objc-common.h c-tree.h c-typeck.c 
	                 langhooks-def.h langhooks.c langhooks.h tree.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/gcc.c-torture/compile: pr22013-1.c 
	gcc/testsuite/gcc.c-torture/execute: pr22098-1.c pr22098-2.c 
	                                     pr22098-3.c 

Log message:
	PR c/22013
	PR c/22098
	* langhooks.h (struct lang_hooks): Add expr_to_decl.
	* langhooks.c (lhd_expr_to_decl): New.
	* langhooks-def.h (lhd_expr_to_decl, LANG_HOOKS_EXPR_TO_DECL):
	New.
	(LANG_HOOKS_INITIALIZER): Update.
	* tree.c (recompute_tree_invarant_for_addr_expr): Call
	expr_to_decl langhook.
	* c-tree.h (c_expr_to_decl): Declare.
	* c-typeck.c (c_expr_to_decl): New.
	(build_unary_op): Do not handle ADDR_EXPR of COMPOUND_LITERAL_EXPR
	specially.
	* c-objc-common.h (LANG_HOOKS_EXPR_TO_DECL): Define.
	
	testsuite:
	* gcc.c-torture/compile/pr22013-1.c,
	gcc.c-torture/execute/pr22098-1.c,
	gcc.c-torture/execute/pr22098-2.c,
	gcc.c-torture/execute/pr22098-3.c: New tests.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.9345&r2=2.9346
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/c-objc-common.h.diff?cvsroot=gcc&r1=2.7&r2=2.8
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/c-tree.h.diff?cvsroot=gcc&r1=1.207&r2=1.208
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/c-typeck.c.diff?cvsroot=gcc&r1=1.463&r2=1.464
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/langhooks-def.h.diff?cvsroot=gcc&r1=1.99&r2=1.100
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/langhooks.c.diff?cvsroot=gcc&r1=1.83&r2=1.84
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/langhooks.h.diff?cvsroot=gcc&r1=1.107&r2=1.108
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/tree.c.diff?cvsroot=gcc&r1=1.493&r2=1.494
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.5725&r2=1.5726
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.c-torture/compile/pr22013-1.c.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.c-torture/execute/pr22098-1.c.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.c-torture/execute/pr22098-2.c.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.c-torture/execute/pr22098-3.c.diff?cvsroot=gcc&r1=NONE&r2=1.1

Comment 7 GCC Commits 2005-07-08 13:09:05 UTC
Subject: Bug 22013

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-4_0-branch
Changes by:	jsm28@gcc.gnu.org	2005-07-08 13:08:15

Modified files:
	gcc            : ChangeLog c-objc-common.h c-tree.h c-typeck.c 
	                 langhooks-def.h langhooks.c langhooks.h tree.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/gcc.c-torture/compile: pr22013-1.c 
	gcc/testsuite/gcc.c-torture/execute: pr22098-1.c pr22098-2.c 
	                                     pr22098-3.c 

Log message:
	PR c/22013
	PR c/22098
	* langhooks.h (struct lang_hooks): Add expr_to_decl.
	* langhooks.c (lhd_expr_to_decl): New.
	* langhooks-def.h (lhd_expr_to_decl, LANG_HOOKS_EXPR_TO_DECL):
	New.
	(LANG_HOOKS_INITIALIZER): Update.
	* tree.c (recompute_tree_invarant_for_addr_expr): Call
	expr_to_decl langhook.
	* c-tree.h (c_expr_to_decl): Declare.
	* c-typeck.c (c_expr_to_decl): New.
	(build_unary_op): Do not handle ADDR_EXPR of COMPOUND_LITERAL_EXPR
	specially.
	* c-objc-common.h (LANG_HOOKS_EXPR_TO_DECL): Define.
	
	testsuite:
	* gcc.c-torture/compile/pr22013-1.c,
	gcc.c-torture/execute/pr22098-1.c,
	gcc.c-torture/execute/pr22098-2.c,
	gcc.c-torture/execute/pr22098-3.c: New tests.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=2.7592.2.297&r2=2.7592.2.298
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/c-objc-common.h.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=2.4&r2=2.4.2.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/c-tree.h.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.193.4.4&r2=1.193.4.5
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/c-typeck.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.419.2.7&r2=1.419.2.8
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/langhooks-def.h.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.97&r2=1.97.2.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/langhooks.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.81&r2=1.81.2.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/langhooks.h.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.104&r2=1.104.2.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/tree.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.466.4.4&r2=1.466.4.5
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.5084.2.249&r2=1.5084.2.250
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.c-torture/compile/pr22013-1.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=NONE&r2=1.1.6.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.c-torture/execute/pr22098-1.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=NONE&r2=1.1.6.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.c-torture/execute/pr22098-2.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=NONE&r2=1.1.6.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.c-torture/execute/pr22098-3.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=NONE&r2=1.1.6.1

Comment 8 Andrew Pinski 2005-07-08 14:48:08 UTC
Fixed for 4.0.2 and above.