Bug 9928 - [3.3/3.4 regression] ICE on duplicate enum declaration
Summary: [3.3/3.4 regression] ICE on duplicate enum declaration
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 3.4.0
: P3 normal
Target Milestone: 3.4.0
Assignee: Eric Botcazou
URL:
Keywords: ice-on-invalid-code
Depends on:
Blocks:
 
Reported: 2003-03-03 23:26 UTC by snyder
Modified: 2004-01-17 04:22 UTC (History)
4 users (show)

See Also:
Host: i686-pc-linux-gnu
Target: i686-pc-linux-gnu
Build: i686-pc-linux-gnu
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description snyder 2003-03-03 23:26:01 UTC
gcc dies with a SEGV compiling the (invalid) code below:

$ ./cc1 x.c
x.c:2: error: conflicting types for `CODES'
x.c:1: error: previous declaration of `CODES'
x.c:2: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://www.gnu.org/software/gcc/bugs.html> for instructions.
$

Here's where it's dying:

Program received signal SIGSEGV, Segmentation fault.
0x0839d43a in int_fits_type_p (c=0x0, type=0x4001e3cc) at ../../gcc/gcc/tree.c:4046
4046            return (! INT_CST_LT (TYPE_MAX_VALUE (type), c)
(gdb) where
#0  0x0839d43a in int_fits_type_p (c=0x0, type=0x4001e3cc) at ../../gcc/gcc/tree.c:4046
#1  0x08071a1b in finish_enum (enumtype=0x4004fd80, values=0x40038d48, attributes=0x0) at ../../gcc/gcc/c-decl.c:5564
#2  0x0804fe2b in yyparse () at c-parse.y:1692
#3  0x0805d145 in c_common_parse_file (set_yydebug=0) at ../../gcc/gcc/c-lex.c:165
During symbol reading, struct/union type gets multiply defined: struct rtx_def.
During symbol reading, struct/union type gets multiply defined: struct rtvec_def.
During symbol reading, struct/union type gets multiply defined: struct function.
#4  0x08386db5 in compile_file () at ../../gcc/gcc/toplev.c:2187
#5  0x0838d9d7 in do_compile (no_backend=0) at ../../gcc/gcc/toplev.c:5517
#6  0x0838da56 in toplev_main (argc=2, argv=0xbfffc0a4) at ../../gcc/gcc/toplev.c:5557
#7  0x080cee6c in main (argc=2, argv=0xbfffc0a4) at ../../gcc/gcc/main.c:37

Release:
3.4 20030303 (experimental)

Environment:
System: Linux karma 2.4.19-emp_2419p5a829i #1 Tue Sep 3 17:42:17 EST 2002 i686 unknown
Architecture: i686

	<machine, os, target, libraries (multiple lines)>
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: ../gcc/configure --prefix=/usr/local/gcc --enable-threads=posix --enable-long-long : (reconfigured)

How-To-Repeat:
--------------------------------------------------
enum { CODES };
enum { CODES };
--------------------------------------------------
Comment 1 snyder 2003-03-03 23:26:01 UTC
Fix:
	<how to correct or work around the problem, if known (multiple lines)>
Comment 2 Wolfgang Bangerth 2003-03-03 23:37:28 UTC
State-Changed-From-To: open->analyzed
State-Changed-Why: Confirmed. With 3.2, we just get an error:
    g/x> /home/bangerth/bin/gcc-3.2.2-pre/bin/gcc -c x.c
    x.c:2: conflicting types for `CODES'
    x.c:1: previous declaration of `CODES'
    
    3.3 bails out, which has of course the same source as 3.4
    ICEing:
    g/x> /home/bangerth/bin/gcc-3.3-pre/bin/gcc -c x.c
    x.c:2: error: conflicting types for `CODES'
    x.c:1: error: previous declaration of `CODES'
    x.c:2: confused by earlier errors, bailing out
    
    g/x> /home/bangerth/bin/gcc-3.4-pre/bin/gcc -c x.c
    x.c:2: error: conflicting types for `CODES'
    x.c:1: error: previous declaration of `CODES'
    x.c:2: internal compiler error: Segmentation fault
    
    Since 3.2 did not ICE, this is a regression.
    
    W.
Comment 3 Steven Bosscher 2003-03-11 14:04:39 UTC
Responsible-Changed-From-To: unassigned->ebotcazou
Responsible-Changed-Why: per his request
Comment 4 s.bosscher 2003-03-11 14:28:18 UTC
From: Steven Bosscher <s.bosscher@student.tudelft.nl>
To: gcc-gnats@gcc.gnu.org, gcc-bugs@gcc.gnu.org, nobody@gcc.gnu.org,
	ebotcazou@libertysurf.fr, snyder@fnal.gov
Cc:  
Subject: Re: c/9928: [3.3/3.4 regression] ICE on duplicate enum declaration
Date: Tue, 11 Mar 2003 14:28:18 +0100

 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=9928
 
 This PR was introduced with Eric's patch that fixed another ICE (for 
 c/7741):
 http://gcc.gnu.org/ml/gcc-patches/2003-02/msg00641.html
 
 So we've exchanged one ICE for another :-)
 
 Greetz
 Steven
 
 

Comment 5 Eric Botcazou 2003-03-11 14:53:28 UTC
From: Eric Botcazou <ebotcazou@libertysurf.fr>
To: Steven Bosscher <s.bosscher@student.tudelft.nl>
Cc: gcc-gnats@gcc.gnu.org,
 gcc-bugs@gcc.gnu.org,
 nobody@gcc.gnu.org,
 snyder@fnal.gov
Subject: Re: c/9928: [3.3/3.4 regression] ICE on duplicate enum declaration
Date: Tue, 11 Mar 2003 14:53:28 +0100

 > This PR was introduced with Eric's patch that fixed another ICE (for
 > c/7741): http://gcc.gnu.org/ml/gcc-patches/2003-02/msg00641.html
 
 Thanks for spotting this! Please assign the PR to me.
 
 -- 
 Eric Botcazou
Comment 6 s.bosscher 2003-03-12 01:10:20 UTC
From: Steven Bosscher <s.bosscher@student.tudelft.nl>
To: gcc-gnats@gcc.gnu.org, gcc-bugs@gcc.gnu.org, gcc-prs@gcc.gnu.org,
	snyder@fnal.gov, ebotcazou@gcc.gnu.org
Cc:  
Subject: Re: c/9928: [3.3/3.4 regression] ICE on duplicate enum declaration
Date: Wed, 12 Mar 2003 01:10:20 +0100

 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=9928
 
 Patch pending: http://gcc.gnu.org/ml/gcc-patches/2003-03/msg00972.html
 

Comment 7 Eric Botcazou 2003-03-12 09:54:38 UTC
From: ebotcazou@gcc.gnu.org
To: gcc-gnats@gcc.gnu.org
Cc:  
Subject: c/9928
Date: 12 Mar 2003 09:54:38 -0000

 CVSROOT:	/cvs/gcc
 Module name:	gcc
 Changes by:	ebotcazou@gcc.gnu.org	2003-03-12 09:54:38
 
 Modified files:
 	gcc            : ChangeLog c-decl.c 
 	gcc/testsuite  : ChangeLog 
 Added files:
 	gcc/testsuite/gcc.dg: decl-3.c 
 
 Log message:
 	PR c/9928
 	* c-decl.c (duplicate_decls): Discard the initializer of the new decl
 	only if it is a VAR_DECL.
 
 Patches:
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=1.17041&r2=1.17042
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/c-decl.c.diff?cvsroot=gcc&r1=1.368&r2=1.369
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.2499&r2=1.2500
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/decl-3.c.diff?cvsroot=gcc&r1=NONE&r2=1.1
 

Comment 8 Eric Botcazou 2003-03-12 09:59:52 UTC
From: ebotcazou@gcc.gnu.org
To: gcc-gnats@gcc.gnu.org
Cc:  
Subject: c/9928
Date: 12 Mar 2003 09:59:52 -0000

 CVSROOT:	/cvs/gcc
 Module name:	gcc
 Branch: 	gcc-3_3-branch
 Changes by:	ebotcazou@gcc.gnu.org	2003-03-12 09:59:52
 
 Modified files:
 	gcc            : ChangeLog c-decl.c 
 	gcc/testsuite  : ChangeLog 
 Added files:
 	gcc/testsuite/gcc.dg: decl-3.c 
 
 Log message:
 	PR c/9928
 	* c-decl.c (duplicate_decls): Discard the initializer of the new decl
 	only if it is a VAR_DECL.
 
 Patches:
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.16114.2.287&r2=1.16114.2.288
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/c-decl.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.356.2.2&r2=1.356.2.3
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.2261.2.92&r2=1.2261.2.93
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/decl-3.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=NONE&r2=1.1.2.1
 

Comment 10 Eric Botcazou 2003-03-12 10:14:30 UTC
State-Changed-From-To: analyzed->closed
State-Changed-Why: Fixed.