Bug 16676 - [3.4 Regression] ICE with nested functions and -g1, blocks glibc
Summary: [3.4 Regression] ICE with nested functions and -g1, blocks glibc
Status: RESOLVED WONTFIX
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 3.4.1
: P2 normal
Target Milestone: 3.4.6
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-valid-code, monitored
: 21457 24304 (view as bug list)
Depends on:
Blocks:
 
Reported: 2004-07-22 20:55 UTC by Kurt Roeckx
Modified: 2006-02-28 09:37 UTC (History)
7 users (show)

See Also:
Host:
Target:
Build:
Known to work: 3.2.3 3.3.4 4.0.0
Known to fail: 3.4.0 3.4.4
Last reconfirmed: 2006-01-10 03:50:12


Attachments
OpenPGP digital signature (221 bytes, application/pgp-signature)
2005-06-01 10:02 UTC, bje@au1.ibm.com
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Kurt Roeckx 2004-07-22 20:55:33 UTC
I get an internal compiler error using the debian 3.4.1-2 version.  I don't get 
it using 3.3.4.  I also get the same error using the gcc snapsnot (3.5.0 
20040717)

I get the same error on i386 and x86_64/amd64.

I only get the error when using -g1, using -g0 it works.  It does not depend on 
the -O level used.

I've also filed a bug at http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=260710
which has a preprocessed file attached to it.

Kurt
Comment 1 Wolfgang Bangerth 2004-07-22 21:20:35 UTC
Confirmed. I'll try to shrink it. 
W. 
Comment 2 Andrew Pinski 2004-07-22 21:21:08 UTC
Confirmed, here is the reduced source:
int t()
{
  static int g() {return 0;}
  return g();
}

I hate nested functions.
Comment 3 Wolfgang Bangerth 2004-07-22 21:24:50 UTC
That one was actually easy: 
------------------- 
void foo (void) { 
  void nested () {} 
} 
------------------- 
 
g/x> /home/bangerth/bin/gcc-3.4-pre/bin/gcc -g1 -c x.i  
x.i: In function `foo': 
x.i:3: internal compiler error: in gen_subprogram_die, at dwarf2out.c:10831 
Please submit a full bug report, 
with preprocessed source if appropriate. 
See <URL:http://gcc.gnu.org/bugs.html> for instructions. 
 
W. 
Comment 4 Wolfgang Bangerth 2004-07-22 21:26:11 UTC
Oh, I see Andrew found it easy, too :-) Too bad to be beaten by a mere 
3 minutes... 
Comment 5 Andrew Pinski 2004-07-22 21:42:36 UTC
: Search converges between 2003-04-11-trunk (#226) and 2003-04-12-trunk (#227).
Comment 6 Volker Reichelt 2004-08-25 14:08:39 UTC
Zack, the regression was introduced by your patch
http://gcc.gnu.org/ml/gcc-cvs/2003-04/msg00555.html

Could you please have a look?
Comment 7 Mark Mitchell 2004-08-29 18:12:05 UTC
Postponed until GCC 3.4.3.
Comment 8 Mark Mitchell 2004-08-29 18:14:44 UTC
Postponed until GCC 3.4.3.
Comment 9 Volker Reichelt 2004-09-22 09:13:11 UTC
Fixed on mainline by Jan's patch for PR 16460
http://gcc.gnu.org/ml/gcc-cvs/2004-09/msg00904.html

Jan, do you think the relevant stuff can be backported to 3.4?
Comment 10 Andrew Pinski 2004-09-22 11:57:19 UTC
It is not feasable to backport his fix as uses the unnessted functions which were added for tree-ssa.
Comment 11 Mark Mitchell 2004-11-01 00:45:42 UTC
Postponed until GCC 3.4.4.
Comment 12 Andrew Pinski 2005-05-09 00:03:53 UTC
*** Bug 21457 has been marked as a duplicate of this bug. ***
Comment 13 benh 2005-05-09 00:29:59 UTC
Note that the use of -g1 on glibc NPTL build is a debian rule, I don't know if
anybody else does that and I don't know why they do that, some obscure comment
seem to imply it is to get unwind informations.
Comment 14 Giovanni Bajo 2005-05-09 07:07:28 UTC
Zack, this is a regression of part of your c-decl stuff. Can you possibly give 
it a look? It breaks builds of glibc on primary platforms.
Comment 15 benh 2005-05-09 07:11:00 UTC
Ben Elliston just produced a patch for it that I tested. It fixed building of
glibc on debian powerpc with -g1 (used by debian rules for nptl).

The patch is on it's way to the patch list (which didn't catch up yet it seems).
The patch is very simple, it just causes gcc to emit more debug infos in the
case of nested functions (like the -g2 case) instead of trying to be smart.
Comment 16 GCC Commits 2005-05-10 00:02:10 UTC
Subject: Bug 16676

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-3_4-branch
Changes by:	bje@gcc.gnu.org	2005-05-10 00:01:46

Modified files:
	gcc            : ChangeLog dwarf2out.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/gcc.dg/debug: pr16676.c 

Log message:
	PR debug/16676
	* dwarf2out.c (dwarf2out_decl): Always set context_die to NULL,
	even when debug_info_level is DINFO_LEVEL_TERSE.
	
	[testsuite]
	* gcc.dg/debug/pr16676.c: New test.

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.858&r2=2.2326.2.859
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/dwarf2out.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.478.2.16&r2=1.478.2.17
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.392&r2=1.3389.2.393
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/debug/pr16676.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.2.1

Comment 17 Ben Elliston 2005-05-10 01:24:11 UTC
Patch approved by rth and committed.
Comment 18 Volker Reichelt 2005-05-25 09:36:39 UTC
Ben, your patch doesn't really solve the problem.
I still get the ICE on the 3.4 branch when I compile the testcase with -g1.
Comment 19 bje@au1.ibm.com 2005-06-01 10:02:22 UTC
Subject: Re:  [3.4 Regression] ICE with nested functions and
 -g1, blocks glibc

> Ben, your patch doesn't really solve the problem.
> I still get the ICE on the 3.4 branch when I compile the testcase with -g1.

A number of people discovered some regressions that I missed, so I have backed the
patch out for now.
Comment 20 bje@au1.ibm.com 2005-06-01 10:02:24 UTC
Created attachment 9006 [details]
OpenPGP digital signature
Comment 21 Richard Biener 2005-09-09 10:31:37 UTC
As this _only_ happens with -O1 -g1 (not -O2 -g1, nor -O1 -g) this is surely not
critical (anymore anyways).  Re-confirmed on 3.4.4 though.  Also this is likely
not to be fixed.
Comment 22 Andrew Pinski 2005-10-11 11:25:15 UTC
*** Bug 24304 has been marked as a duplicate of this bug. ***
Comment 23 Gabriel Dos Reis 2006-02-28 09:37:42 UTC
won't fix for 3.4.6.