Bug 14114 - [4.0 Regression] [unit-at-a-time] ICE in gen_subprogram_die
Summary: [4.0 Regression] [unit-at-a-time] ICE in gen_subprogram_die
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 3.4.0
: P3 normal
Target Milestone: 4.0.0
Assignee: Zack Weinberg
URL:
Keywords: ice-on-valid-code, patch
: 14139 (view as bug list)
Depends on:
Blocks:
 
Reported: 2004-02-11 20:06 UTC by snyder
Modified: 2005-02-09 02:18 UTC (History)
5 users (show)

See Also:
Host: i686-pc-linux-gnu
Target: i686-pc-linux-gnu
Build: i686-pc-linux-gnu
Known to work: 3.3.3 3.4.0
Known to fail: 4.0.0
Last reconfirmed: 2004-03-10 15:10:06


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description snyder 2004-02-11 20:06:30 UTC
gcc crashes compiling the C code below, if both debugging and optimization
are on:

$ ./cc1 x.c -quiet -g -O2
x.c: In function `a':
x.c:5: internal compiler error: in gen_subprogram_die, at dwarf2out.c:10696
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.
$
[sss@karma gcc]
It's tripping over this abort in gen_subprogram_die:

	  /* ??? This can happen if there is a bug in the program, for
	     instance, if it has duplicate function definitions.  Ideally,
	     we should detect this case and ignore it.  For now, if we have
	     already reported an error, any error at all, then assume that
	     we got here because of an input error, not a dwarf2 bug.  */
	  if (errorcount)
	    return;
	  abort ();

Environment:
System: Linux karma 2.6.1 #10 Tue Feb 10 04:31:35 EST 2004 i686 i686 i386 GNU/Linux
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 --enable-languages=c,c++,f77

How-To-Repeat:

Compile with -g -O2:

---------------------------------------
void a()
{
  void c();
  c();
}

void b()
{
  void c();
}

void c() {}
---------------------------------------
Comment 1 snyder 2004-02-11 20:06:30 UTC
Fix:
	<how to correct or work around the problem, if known (multiple lines)>
Comment 2 Andrew Pinski 2004-02-11 20:47:52 UTC
Confirmed, this is an unit-at-a-time problem.
Comment 3 Andrew Pinski 2004-02-11 20:53:50 UTC
Or it could be caused by Zack's rewrite of c-decl.c I do not know which one because they interact with 
each other.
Comment 4 Andrew Pinski 2004-02-13 15:11:10 UTC
*** Bug 14139 has been marked as a duplicate of this bug. ***
Comment 5 Eric Botcazou 2004-03-01 20:27:24 UTC
Investigating.
Comment 6 Eric Botcazou 2004-03-06 09:23:19 UTC
We eventually sort of agreed that this is a C front-end problem.
Comment 7 GCC Commits 2004-03-06 09:28:58 UTC
Subject: Bug 14114

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	ebotcazou@gcc.gnu.org	2004-03-06 09:28:51

Modified files:
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/gcc.dg: decl-5.c 

Log message:
	PR c/14114
	* gcc.dg/decl-5.c: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.3572&r2=1.3573
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/decl-5.c.diff?cvsroot=gcc&r1=NONE&r2=1.1

Comment 9 Eric Botcazou 2004-03-06 09:46:02 UTC
Fixed on the 3.4 branch: http://gcc.gnu.org/ml/gcc-patches/2004-03/msg00258.html

Zack doesn't want the patch to interfere with his new c-decl.c rewrite.
Comment 11 Eric Botcazou 2004-03-11 06:32:53 UTC
Patch: http://gcc.gnu.org/ml/gcc-patches/2004-03/msg00724.html
Comment 12 Mark Mitchell 2004-03-13 15:44:49 UTC
Subject: Re:  [3.4/3.5 Regression] [unit-at-a-time] ICE in gen_subprogram_die

This patch is OK for 3.4.0.

Comment 13 GCC Commits 2004-03-13 19:05:54 UTC
Subject: Bug 14114

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-3_4-branch
Changes by:	ebotcazou@gcc.gnu.org	2004-03-13 19:05:48

Modified files:
	gcc            : ChangeLog c-decl.c 
	gcc/testsuite  : ChangeLog 
	gcc/testsuite/gcc.dg: decl-5.c 

Log message:
	PR c/14114
	* c-decl.c (merge_decls): Do not copy the C_DECL_INVISIBLE flag
	from the new decl to the old decl.
	(pushdecl): Use lookup_name to search for a previous decl with the
	same identifier.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=2.2326.2.339&r2=2.2326.2.340
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/c-decl.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.470.4.9&r2=1.470.4.10
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.3389.2.143&r2=1.3389.2.144
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/decl-5.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.1.2.3&r2=1.1.2.4

Comment 14 Eric Botcazou 2004-03-13 19:08:50 UTC
Fixed on 3.4 branch.

Zack, I reassign the PR to you.  Let me know if I can do anything else.
Comment 15 Zack Weinberg 2004-03-16 20:57:50 UTC
Fixed by the c-decl.c rewrite:
http://gcc.gnu.org/ml/gcc-patches/2004-03/msg01280.html
Comment 16 Zack Weinberg 2004-03-23 23:54:24 UTC
Now fixed in 3.5.