Bug 44982 - [4.9 /5/6 Regression] ICE in get_narrower, at tree.c:7832
Summary: [4.9 /5/6 Regression] ICE in get_narrower, at tree.c:7832
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.4.1
: P5 normal
Target Milestone: 4.9.4
Assignee: Steven Bosscher
URL:
Keywords: error-recovery, ice-on-invalid-code
Depends on:
Blocks:
 
Reported: 2010-07-19 00:26 UTC by Otto Järvinen
Modified: 2015-12-29 02:17 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work: 3.4.6
Known to fail: 4.0.0
Last reconfirmed: 2010-07-19 09:58:25


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Otto Järvinen 2010-07-19 00:26:38 UTC
otto@lonkero:~/code$ gcc bug.c -Wall

bug.c: In function ‘main’:
bug.c:5: error: void value not ignored as it ought to be
bug.c:5: error: void value not ignored as it ought to be
bug.c:5: confused by earlier errors, bailing out
Preprocessed source stored into /tmp/ccoFNCjw.out file, please attach this to your bugreport.

otto@lonkero:~/code$ cat /tmp/ccoFNCjw.out

// /usr/lib/gcc/i486-linux-gnu/4.4.1/cc1 -quiet bug.c -D_FORTIFY_SOURCE=2 -quiet -dumpbase bug.c -mtune=generic -march=i486 -auxbase bug -Wall -fstack-protector -o - -frandom-seed=0
# 1 "bug.c"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "bug.c"
int main(void)
{
   int a=1;

   if((a==1) ? (void) (0) : 1);

   return 0;
}
Comment 1 Richard Biener 2010-07-19 09:12:55 UTC
Confirmed.

./cc1 -quiet t.c
t.c: In function 'main':
t.c:5:3: error: void value not ignored as it ought to be
t.c:5:3: error: void value not ignored as it ought to be
t.c:5:5: internal compiler error: tree check: expected class 'type', have 'exceptional' (error_mark) in get_narrower, at tree.c:7832
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.
Comment 2 Steven Bosscher 2010-07-19 09:58:25 UTC
Should be easy, this one. I like easy.
Comment 3 Steven Bosscher 2010-12-17 21:26:45 UTC
I see no reason to cgraph_finalize_compilation_unit if there were parse errors. Richi, what do you think?


Index: toplev.c
===================================================================
--- toplev.c	(revision 167996)
+++ toplev.c	(working copy)
@@ -582,7 +582,12 @@
      what's left of the symbol table output.  */
   timevar_pop (TV_PARSE);
 
-  if (flag_syntax_only || flag_wpa)
+  /* If all we have to do is syntax checking, or if there were parse
+     errors, stop here.  */
+  if (flag_syntax_only || seen_error)
+    return;
+
+  if (flag_wpa)
     return;
 
   ggc_protect_identifiers = false;
@@ -590,9 +595,6 @@
   /* This must also call cgraph_finalize_compilation_unit.  */
   lang_hooks.decls.final_write_globals ();
 
-  if (seen_error ())
-    return;
-
   varpool_assemble_pending_decls ();
   finish_aliases_2 ();
Comment 4 rguenther@suse.de 2010-12-18 20:22:18 UTC
On Fri, 17 Dec 2010, steven at gcc dot gnu.org wrote:

> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44982
> 
> Steven Bosscher <steven at gcc dot gnu.org> changed:
> 
>            What    |Removed                     |Added
> ----------------------------------------------------------------------------
>                  CC|                            |rguenth at gcc dot gnu.org
> 
> --- Comment #3 from Steven Bosscher <steven at gcc dot gnu.org> 2010-12-17 21:26:45 UTC ---
> I see no reason to cgraph_finalize_compilation_unit if there were parse errors.
> Richi, what do you think?

I think the idea was we want to preserve warnings and errors we generate
from the middle-end.  But the patch looks sensible to me anyway, maybe
post it up for disscussion, as it would affect all frontends.

Richard.

> 
> Index: toplev.c
> ===================================================================
> --- toplev.c    (revision 167996)
> +++ toplev.c    (working copy)
> @@ -582,7 +582,12 @@
>       what's left of the symbol table output.  */
>    timevar_pop (TV_PARSE);
> 
> -  if (flag_syntax_only || flag_wpa)
> +  /* If all we have to do is syntax checking, or if there were parse
> +     errors, stop here.  */
> +  if (flag_syntax_only || seen_error)
> +    return;
> +
> +  if (flag_wpa)
>      return;
> 
>    ggc_protect_identifiers = false;
> @@ -590,9 +595,6 @@
>    /* This must also call cgraph_finalize_compilation_unit.  */
>    lang_hooks.decls.final_write_globals ();
> 
> -  if (seen_error ())
> -    return;
> -
>    varpool_assemble_pending_decls ();
>    finish_aliases_2 ();
> 
>
Comment 5 Richard Biener 2011-06-27 12:13:37 UTC
4.3 branch is being closed, moving to 4.4.7 target.
Comment 6 Jakub Jelinek 2012-03-13 12:46:36 UTC
4.4 branch is being closed, moving to 4.5.4 target.
Comment 7 Jakub Jelinek 2013-04-12 15:16:29 UTC
GCC 4.6.4 has been released and the branch has been closed.
Comment 8 Richard Biener 2014-06-12 13:44:00 UTC
The 4.7 branch is being closed, moving target milestone to 4.8.4.
Comment 9 Jakub Jelinek 2014-12-19 13:34:09 UTC
GCC 4.8.4 has been released.
Comment 10 tbsaunde 2015-01-15 01:22:01 UTC
(In reply to Richard Biener from comment #1)
> Confirmed.

hm, wfm, but it looks like the patch in comment 3 wasn't applied.  Is there something to do here?
Comment 11 rguenther@suse.de 2015-01-15 08:28:40 UTC
On Thu, 15 Jan 2015, tbsaunde at gcc dot gnu.org wrote:

> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=44982
> 
> tbsaunde at gcc dot gnu.org changed:
> 
>            What    |Removed                     |Added
> ----------------------------------------------------------------------------
>                  CC|                            |tbsaunde at gcc dot gnu.org
> 
> --- Comment #10 from tbsaunde at gcc dot gnu.org ---
> (In reply to Richard Biener from comment #1)
> > Confirmed.
> 
> hm, wfm, but it looks like the patch in comment 3 wasn't applied.  Is there
> something to do here?

Not sure if it was posted or tested - so maybe just do a bootstrap & 
regtest with all languages and if that succeeds the patch  (with the
testcase) is preapproved.
Comment 12 tbsaunde 2015-01-17 21:48:08 UTC
(In reply to rguenther@suse.de from comment #11)
> On Thu, 15 Jan 2015, tbsaunde at gcc dot gnu.org wrote:
> 
> > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=44982
> > 
> > tbsaunde at gcc dot gnu.org changed:
> > 
> >            What    |Removed                     |Added
> > ----------------------------------------------------------------------------
> >                  CC|                            |tbsaunde at gcc dot gnu.org
> > 
> > --- Comment #10 from tbsaunde at gcc dot gnu.org ---
> > (In reply to Richard Biener from comment #1)
> > > Confirmed.
> > 
> > hm, wfm, but it looks like the patch in comment 3 wasn't applied.  Is there
> > something to do here?
> 
> Not sure if it was posted or tested - so maybe just do a bootstrap & 
> regtest with all languages and if that succeeds the patch  (with the
> testcase) is preapproved.

there is at least a large number of c++ test cases that fail with the patch.  They all seem to be what you'd expect a file has errors before the new check, and more errors or warnings are expected to be emitted after the new check.  It seems like some part of this setup is crazy, but I'm not really sure what to do about it at this point.
Comment 13 Richard Biener 2015-06-23 08:16:38 UTC
The gcc-4_8-branch is being closed, re-targeting regressions to 4.9.3.
Comment 14 Jakub Jelinek 2015-06-26 19:58:03 UTC
GCC 4.9.3 has been released.
Comment 15 Andrew Pinski 2015-12-29 02:17:45 UTC
This was fixed a long time ago.