Bug 20161 - [4.0/4.1 Regression] ICE with dwarf for incomplete element type argument
Summary: [4.0/4.1 Regression] ICE with dwarf for incomplete element type argument
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: debug (show other bugs)
Version: 4.0.0
: P2 minor
Target Milestone: 4.0.2
Assignee: Steven Bosscher
URL: http://gcc.gnu.org/ml/gcc-patches/200...
Keywords: error-recovery, ice-on-invalid-code, patch
Depends on:
Blocks:
 
Reported: 2005-02-23 12:58 UTC by stelios
Modified: 2005-08-04 02:43 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2005-02-23 15:42:59


Attachments
* dwarf2out.c (gen_formal_types_die): Robustify. (525 bytes, patch)
2005-02-24 21:57 UTC, Steven Bosscher
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description stelios 2005-02-23 12:58:30 UTC
First of all the typescript:
##############################################
stan@vaxatron:~/wtmp> cat gb.c

struct XX;
typedef void *(*F) (struct XX []);

stan@vaxatron:~/wtmp> CVSgcc gb.c -Wall -g
gb.c:3: error: array type has incomplete element type
gb.c:3: internal compiler error: in gen_formal_parameter_die, at dwarf2out.c:11062
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.
stan@vaxatron:~/wtmp> CVSgcc -v
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: ../configure --prefix=/home/stan/GCC/gcc-4.0-20050220/bin
--program-prefix=CVS : (reconfigured) ../configure
--prefix=/home/stan/GCC/gcc-4.0-20050220/bin --program-prefix=CVS
Thread model: posix
gcc version 4.0.0 20050220 (experimental)
######################################################

Except from the internal compiler error, is it a bug that
gcc considers the incomplete type an error?
If yes, then this is even more critical.

In 3.4 and 3.2 the above code was Ok.
Comment 1 Andrew Pinski 2005-02-23 13:04:22 UTC
The code is invalid as mentioned before in other bugs.

Confirmed, a regression.
Comment 2 Steven Bosscher 2005-02-24 21:57:09 UTC
Created attachment 8277 [details]
* dwarf2out.c (gen_formal_types_die): Robustify.

I'll test this a bit and post it if it looks OK.
Comment 3 Flash Sheridan 2005-07-26 04:09:33 UTC
PalmSource bug 105106.  Happens on code which is supposedly valid, but I 
haven't verified that. 
Comment 4 Steven Bosscher 2005-07-26 10:18:13 UTC
Let's try this patch then. 
 
Index: passes.c 
=================================================================== 
RCS file: /cvs/gcc/gcc/gcc/passes.c,v 
retrieving revision 2.105 
diff -u -3 -p -r2.105 passes.c 
--- passes.c    19 Jul 2005 18:45:56 -0000      2.105 
+++ passes.c    26 Jul 2005 10:12:55 -0000 
@@ -175,7 +175,10 @@ rest_of_decl_compilation (tree decl, 
 
       timevar_pop (TV_VARCONST); 
     } 
-  else if (TREE_CODE (decl) == TYPE_DECL) 
+  else if (TREE_CODE (decl) == TYPE_DECL 
+          /* Like in rest_of_type_compilation, avoid confusing the debug 
+             information machinery when there are errors.  */ 
+          && !(sorrycount || errorcount)) 
     { 
       timevar_push (TV_SYMOUT); 
       debug_hooks->type_decl (decl, !top_level); 
 
Comment 5 GCC Commits 2005-07-28 01:24:27 UTC
Subject: Bug 20161

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	steven@gcc.gnu.org	2005-07-28 01:24:20

Modified files:
	gcc            : ChangeLog passes.c 

Log message:
	PR debug/20161
	* passes.c (rest_of_decl_compilation): If decl is a type and
	we have encountered errors, don't emit debug information.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.9572&r2=2.9573
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/passes.c.diff?cvsroot=gcc&r1=2.105&r2=2.106

Comment 6 Steven Bosscher 2005-07-28 01:25:07 UTC
be fixeth, buglette! 
Comment 7 GCC Commits 2005-07-28 01:29:15 UTC
Subject: Bug 20161

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-4_0-branch
Changes by:	steven@gcc.gnu.org	2005-07-28 01:28:59

Modified files:
	gcc            : passes.c ChangeLog 

Log message:
	PR debug/20161
	* passes.c (rest_of_decl_compilation): If decl is a type and
	we have encountered errors, don't emit debug information.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/passes.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=2.72.2.2&r2=2.72.2.3
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=2.7592.2.334&r2=2.7592.2.335

Comment 8 Flash Sheridan 2005-08-02 22:05:58 UTC
The patch looks good on the first of our files to elicit this bug.  The following line causes the ICE; the line 
after does not. 
/opt2/gcc401-chkall-9330/bin/g++  -g    ../cpp/bugfiles/GCC_bugfiles/error/105106_jdinput.c

/opt2/gcc401-chkall-8277-9330/bin/g++  -g    ../cpp/bugfiles/GCC_bugfiles/error/105106_jdinput.c

I'll crash test the checking=yes version overnight.  (Note that so far I'm only crash-testing; I'm not yet 
doing correctness testing.)
Comment 9 Flash Sheridan 2005-08-04 02:43:51 UTC
The patch looked good in overnight crash-testing over five thousand files in 
our source tree.  I used checking=yes version with patches 8277 and 9330.  I'm 
afraid last night's results aren't directly comparable to my last run with an 
unpatched g++, but the internal errors were a small subset of the unpatched 
version, 4 vs 30.  (Two of those four were bug 23125, one was 23089, and I'll 
file the other one.)