falk@juist:/tmp% cat min.c foo() enum { a = b }; falk@juist:/tmp% gcc --version gcc (GCC) 3.5-tree-ssa 20031009 (merged 20031005) Copyright (C) 2003 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. falk@juist:/tmp% gcc -c min.c min.c: In function `foo': min.c:2: error: `b' undeclared (first use in this function) min.c:2: error: (Each undeclared identifier is reported only once min.c:2: error: for each function it appears in.) min.c:2: internal compiler error: Segmentation fault Please submit a full bug report, with preprocessed source if appropriate. See <URL:http://gcc.gnu.org/bugs.html> for instructions.
It also happens on the mainline (20031009). Also it is a regression from 3.3.1. undeclared_variable (id=0x40100f40) at /home/gates/pinskia/src/gnu/gcc/src/gcc/c-decl.c:1967 1967 scope->shadowed = tree_cons (id, IDENTIFIER_SYMBOL_VALUE (id), (gdb) bt #0 undeclared_variable (id=0x40100f40) at /home/gates/pinskia/src/gnu/gcc/src/gcc/c- decl.c:1967 #1 0x080783dc in build_external_ref (id=0x40100f40, fun=0) at /home/gates/pinskia/src/gnu/ gcc/src/gcc/c-typeck.c:1603 #2 0x0804c613 in yyparse () at c-parse.y:596 #3 0x080525db in c_parse_file () at c-parse.y:3033 #4 0x080a3c6b in c_common_parse_file (set_yydebug=2) at /home/gates/pinskia/src/gnu/gcc/ src/gcc/c-opts.c:1226 #5 0x083029b4 in toplev_main (argc=2, argv=0xbffec754) at /home/gates/pinskia/src/gnu/gcc/ src/gcc/toplev.c:1792 #6 0x080c453e in main (argc=2, argv=0x2) at /home/gates/pinskia/src/gnu/gcc/src/gcc/ main.c:35
From Phil's regression hunter: Search converges between 2003-03-17-trunk (#247) and 2003-03 -18-trunk (#248).
The regression was introduced by Zack's patch http://gcc.gnu.org/ml/gcc-patches/2003-03/msg01594.html http://gcc.gnu.org/ml/gcc-cvs/2003-03/msg00901.html Zack, could you please have a look?
Will address this as part of the c-decl.c overhaul I'm doing now.
The problem is that this point current_function_decl is not NULL but current_function_scope is NULL.
I have also seen this when you leave out the closing crucly brace for a function.
As this is just an ICE after a valid error message, we can postpone this until 3.4.1.
Fixed by the c-decl.c rewrite: http://gcc.gnu.org/ml/gcc-patches/2004-03/msg01280.html
fixed in 3.5
As Zack says, it's fixed.