Bug 35433 - [4.2 regression] ICE with typeof and ternary operator
Summary: [4.2 regression] ICE with typeof and ternary operator
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 4.4.0
: P2 normal
Target Milestone: 4.3.4
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-invalid-code, monitored
Depends on:
Blocks:
 
Reported: 2008-03-03 20:23 UTC by Volker Reichelt
Modified: 2009-03-31 15:21 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work: 4.3.4 4.4.0
Known to fail: 4.2.4 4.3.3 4.2.5
Last reconfirmed: 2009-02-03 17:38:08


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Volker Reichelt 2008-03-03 20:23:49 UTC
The following (IMHO valid) code snippet triggers an ICE since GCC 4.1.0:

================================
typedef int* X;
typedef int* Y;

X (*p)[][0];
Y (*q)[][0];

typeof(*(0 ? p : q)) x = { 0 };
================================

bug.c:7: internal compiler error: Segmentation fault
Please submit a full bug report, [etc.]

The code compiled fine with GCC 2.95.3, crashed GCC 3.0.0, 3.0.1,
and was rejected by GCC 3.0.2 - 4.0.4.
Comment 1 Joseph S. Myers 2008-07-04 22:36:41 UTC
Closing 4.1 branch.
Comment 2 Joseph S. Myers 2009-02-03 17:38:08 UTC
Working on a patch.
Comment 3 Joseph S. Myers 2009-02-03 20:38:32 UTC
Subject: Bug 35433

Author: jsm28
Date: Tue Feb  3 20:38:12 2009
New Revision: 143906

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=143906
Log:
	PR c/35433
	* c-typeck.c (composite_type): Set TYPE_SIZE and TYPE_SIZE_UNIT
	for composite type involving a zero-length array type.

testsuite:
	* gcc.dg/init-bad-6.c: New test.

Added:
    trunk/gcc/testsuite/gcc.dg/init-bad-6.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/c-typeck.c
    trunk/gcc/testsuite/ChangeLog

Comment 4 Joseph S. Myers 2009-02-03 20:41:04 UTC
Fixed for 4.4; will fix for 4.3.
Comment 5 Joseph S. Myers 2009-02-04 13:07:54 UTC
Subject: Bug 35433

Author: jsm28
Date: Wed Feb  4 13:07:43 2009
New Revision: 143922

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=143922
Log:
	PR c/35433
	* c-typeck.c (composite_type): Set TYPE_SIZE and TYPE_SIZE_UNIT
	for composite type involving a zero-length array type.

testsuite:
	* gcc.dg/init-bad-6.c: New test.

Added:
    branches/gcc-4_3-branch/gcc/testsuite/gcc.dg/init-bad-6.c
Modified:
    branches/gcc-4_3-branch/gcc/ChangeLog
    branches/gcc-4_3-branch/gcc/c-typeck.c
    branches/gcc-4_3-branch/gcc/testsuite/ChangeLog

Comment 6 Joseph S. Myers 2009-02-04 13:09:34 UTC
Fixed for 4.3.4 and 4.4.0.  Not planning to work on backport to 4.2 branch.
Comment 7 Joseph S. Myers 2009-03-31 15:21:02 UTC
Closing 4.2 branch, fixed for 4.3.4 and 4.4.