Bug 32295 - [4.1 Regression] An invalid c code causes an ICE in create_tmp_var, at gimplify.c:489
Summary: [4.1 Regression] An invalid c code causes an ICE in create_tmp_var, at gimpli...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 4.3.0
: P2 normal
Target Milestone: 4.2.3
Assignee: Not yet assigned to anyone
URL:
Keywords: accepts-invalid, ice-on-invalid-code
: 33448 34819 (view as bug list)
Depends on:
Blocks:
 
Reported: 2007-06-12 00:29 UTC by Kazumoto Kojima
Modified: 2008-07-04 16:09 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Known to work: 3.3.3 4.2.3
Known to fail: 4.1.2 4.1.3 4.2.0 4.3.0
Last reconfirmed: 2007-09-24 17:36:28


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kazumoto Kojima 2007-06-12 00:29:45 UTC
The following invalid code snippet fails with
  foo.c:4: internal compiler error: in create_tmp_var, at gimplify.c:489


static enum warn overflow;
int foo (int code, tree stmt)
{
  if (code == 0 || code > (int) overflow)
    code = overflow;
  return code;
}
Comment 1 Andrew Pinski 2007-06-12 01:18:14 UTC
Reduced testcase:
static enum warn overflow;
int foo (void)
{
 return overflow;
}

I think this is valid GNU C, though invalid standard C.
Comment 2 Andrew Pinski 2007-06-12 01:20:33 UTC
Actually I take that back, this is even invalid GNU C.
3.3 gave:
t.c:1: error: storage size of `overflow' isn't known

While 4.0.4 gave an ICE.  We should have gave an error here.
Comment 3 Jakub Jelinek 2007-08-23 12:38:18 UTC
Another testcase:
extern enum warn overflow;
int
foo (void)
{
  return overflow;
}

Here 3.4.x silently compiled it and used SImode for the variable, eventhough
TYPE_SIZE on the enum warn type nor DECL_SIZE on overflow DECL_EXTERNAL variable
was set.
Comment 4 Andrew Pinski 2007-09-16 15:09:43 UTC
*** Bug 33448 has been marked as a duplicate of this bug. ***
Comment 5 Joseph S. Myers 2007-09-24 17:36:28 UTC
Working on a patch.
Comment 6 Joseph S. Myers 2007-09-25 15:05:12 UTC
Subject: Bug 32295

Author: jsm28
Date: Tue Sep 25 15:04:58 2007
New Revision: 128765

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=128765
Log:
	PR c/32295
	* c-typeck.c (default_conversion): Call require_complete_type
	before perform_integral_promotions.
	(build_unary_op): Call require_complete_type except for ADDR_EXPR.
	(build_c_cast): Call require_complete_type except for casts to
	void types.
	(convert_for_assignment): Call require_complete_type.

testsuite:
	* gcc.dg/enum-incomplete-1.c: New test.

Added:
    trunk/gcc/testsuite/gcc.dg/enum-incomplete-1.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/c-typeck.c
    trunk/gcc/testsuite/ChangeLog

Comment 7 Joseph S. Myers 2007-09-27 12:20:25 UTC
Fixed for 4.3.0.
Comment 8 Joseph S. Myers 2007-10-10 18:24:42 UTC
Subject: Bug 32295

Author: jsm28
Date: Wed Oct 10 18:24:29 2007
New Revision: 129215

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=129215
Log:
	PR c/32295
	* c-typeck.c (default_conversion): Call require_complete_type
	before perform_integral_promotions.
	(build_unary_op): Call require_complete_type except for ADDR_EXPR.
	(build_c_cast): Call require_complete_type except for casts to
	void types.
	(convert_for_assignment): Call require_complete_type.

testsuite:
	* gcc.dg/enum-incomplete-1.c: New test.

Added:
    branches/gcc-4_2-branch/gcc/testsuite/gcc.dg/enum-incomplete-1.c
Modified:
    branches/gcc-4_2-branch/gcc/ChangeLog
    branches/gcc-4_2-branch/gcc/c-typeck.c
    branches/gcc-4_2-branch/gcc/testsuite/ChangeLog

Comment 9 Joseph S. Myers 2007-10-10 18:31:45 UTC
Fixed for 4.2.3.
Comment 10 Andrew Pinski 2008-01-16 20:45:20 UTC
*** Bug 34819 has been marked as a duplicate of this bug. ***
Comment 11 Joseph S. Myers 2008-07-04 16:09:39 UTC
Closing 4.1 branch.