c++/981: g++: missing semicolon causes ice in cp_finish_decl:8218

schmid@snake.iap.physik.tu-darmstadt.de schmid@snake.iap.physik.tu-darmstadt.de
Mon Dec 4 13:06:00 GMT 2000


>Number:         981
>Category:       c++
>Synopsis:       g++: missing semicolon causes ice in cp_finish_decl:8218
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          ice-on-illegal-code
>Submitter-Id:   net
>Arrival-Date:   Mon Dec 04 13:06:01 PST 2000
>Closed-Date:
>Last-Modified:
>Originator:     Peter Schmid
>Release:        2.97 20001127 (experimental)
>Organization:
TU Darmstadt
>Environment:
System: Linux kiste 2.4.0-test11 #21 Thu Nov 30 00:18:12 CET 2000 i686 unknown
Architecture: i686
GNU assembler 001002
GLIBC 2.1.3
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: ../gcc-20001127/configure -enable-shared --disable-nls --enable-threads=posix --enable-long-long --enable-libstdcxx-v3
>Description:
The following simple code crashes the compiler with an internal
compiler error. The code is buggy, a semicolon is missing at line 12.
The compiler cc1plus crashes at line 8218 of the file
gcc-20001127/gcc/cp/decl.c, which reads 
	  if (doing_semantic_analysis_p ())
	    maybe_inject_for_scope_var (decl);.
 
>How-To-Repeat:
source file tadt1.C:

template<class T>
class A
{};

template<class T>
class B {
public:
  static int f();
};

template<class T> 
void g(A<T> &a)   //error semicolon is missing
template<class T> 
void h(A<T> &a, int d);
int main()
{

}

template<class T>
int B<T>::f(){}

template<class T>
void h(A<T> &a, int d)
{
  void *b = &a[d];    
  int c = sizeof(T);       
}

Compiling the programm tadt1.C:
g++ -Q -v tadt1.C -save-temps
Reading specs from /usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.97/specs
Configured with: ../gcc-20001127/configure -enable-shared --disable-nls --enable-threads=posix --enable-long-long --enable-libstdcxx-v3
gcc version 2.97 20001127 (experimental)
 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.97/cpp0 -lang-c++ -v -D__GNUC__=2 -D__GNUC_MINOR__=97 -D__GNUC_PATCHLEVEL__=0 -D__ELF__ -Dunix -Dlinux -D__ELF__ -D__unix__ -D__linux__ -D__unix -D__linux -Asystem=posix -D__STDC_HOSTED__=1 -Acpu=i386 -Amachine=i386 -Di386 -D__i386 -D__i386__ -D__tune_i686__ -D__tune_pentiumpro__ tadt1.C tadt1.ii
GNU CPP version 2.97 20001127 (experimental) (cpplib) (i386 Linux/ELF)
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include/g++-v3
 /usr/local/include
 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.97/include
 /usr/local/i686-pc-linux-gnu/include
 /usr/include
End of search list.
 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.97/cc1plus -fpreprocessed tadt1.ii -D__GNUG__=2 -D__GXX_ABI_VERSION=100 -dumpbase tadt1.C -version -fnew-abi -o tadt1.s
GNU C++ version 2.97 20001127 (experimental) (i686-pc-linux-gnu) compiled by GNU C version 2.97 20001127 (experimental).
options passed:  -fpreprocessed -D__GNUG__=2 -D__GXX_ABI_VERSION=100
 -fnew-abi
options enabled:  -fpeephole -ffunction-cse -fkeep-static-consts
 -fpcc-struct-return -fsched-interblock -fsched-spec -fbranch-count-reg
 -fexceptions -fnew-exceptions -fcommon -fgnu-linker -fargument-alias
 -fident -fmath-errno -m80387 -mhard-float -mno-soft-float -mieee-fp
 -mfp-ret-in-387
 void g(A<T>&)
tadt1.C:13: parse error before "template"

tadt1.C:14: too many template parameter lists in declaration of `void h(A<T>&, 
   int)'
 int main() int main() static int B<T>::f()
tadt1.C:25: too many template parameter lists in declaration of `void h(A<T>&, 
   int)'

tadt1.C:25: syntax error before '{' token

tadt1.C:27: `sizeof' applied to incomplete type `T'

tadt1.C:27: Internal error: Segmentation fault.
confused by earlier errors, bailing out


preprocessor source: tadt1.ii
# 1 "tadt1.C"
template<class T>
class A
{};

template<class T>
class B {
public:
  static int f();
};

template<class T>
void g(A<T> &a)
template<class T>
void h(A<T> &a, int d);
int main()
{

}

template<class T>
int B<T>::f(){}

template<class T>
void h(A<T> &a, int d)
{
  void *b = &a[d];
  int c = sizeof(T);
}

Debugging cc1plus
>Fix:
Current directory is /usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.97/
GNU gdb 5.0
Copyright 2000 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i686-pc-linux-gnu"...
(gdb) cd ~/
Working directory /home/peter/.
(gdb) set args -fnew-abi tadt1.C
(gdb) r
Starting program: /usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.97/cc1plus -fnew-abi tadt1.C
 void g(A<T>&)
tadt1.C:13: parse error before "template"

tadt1.C:14: too many template parameter lists in declaration of `void h(A<T>&, 
   int)'
 int main() int main() static int B<T>::f()
tadt1.C:25: too many template parameter lists in declaration of `void h(A<T>&, 
   int)'

tadt1.C:25: syntax error before '{' token

tadt1.C:27: `sizeof' applied to incomplete type `T'

Program received signal SIGSEGV, Segmentation fault.
0x806bd39 in cp_finish_decl (decl=0x40150a00, init=0x4014fbe0, 
    asmspec_tree=0x0, flags=128) at ../../gcc-20001127/gcc/cp/decl.c:8218
(gdb) l
8213		    DECL_INITIAL (decl) = init;
8214		}
8215	      else if (TREE_CODE (CP_DECL_CONTEXT (decl)) == FUNCTION_DECL)
8216		{
8217		  /* This is a local declaration.  */
8218		  if (doing_semantic_analysis_p ())
8219		    maybe_inject_for_scope_var (decl);
8220		  /* Initialize the local variable.  But, if we're building a
8221		     statement-tree, we'll do the initialization when we
8222		     expand the tree.  */
(gdb) call debug_tree(decl)
 <var_decl 0x40150a00 c
    type <integer_type 0x40136400 int type_6 SI
        size <integer_cst 0x40132680 constant 32>
        unit size <integer_cst 0x401326a0 constant 4>
        align 32 symtab 0 alias set -1 precision 32
        min <integer_cst 0x40132640 constant -2147483648>
        max <integer_cst 0x40132660 constant 2147483647>
        pointer_to_this <pointer_type 0x4013d080>>
    public static SI file tadt1.C line 27 size <integer_cst 0x40132680 32> unit size <integer_cst 0x401326a0 4>
    align 32 context <function_decl 0x40148a80 f> initial <integer_cst 0x4014fca0 0>
    (mem/f:SI (symbol_ref:SI ("c")) 0) chain <function_decl 0x4014e480 main>>
(gdb) bt
#0  0x806bd39 in cp_finish_decl (decl=0x40150a00, init=0x4014fbe0, 
    asmspec_tree=0x0, flags=128) at ../../gcc-20001127/gcc/cp/decl.c:8218
#1  0x80d4fa5 in parse_end_decl (decl=0x40150a00, init=0x4014fbe0, asmspec=0x0)
    at ../../gcc-20001127/gcc/cp/parse.y:159
#2  0x80d8157 in yyparse_1 () at /usr/share/bison.simple:2065
#3  0x814afd7 in compile_file (name=0x847f994 "tadt1.C")
    at ../../gcc-20001127/gcc/toplev.c:2363
#4  0x814eb12 in main (argc=3, argv=0xbffff84c)
    at ../../gcc-20001127/gcc/toplev.c:4840
#5  0x40034a4e in __libc_start_main (main=0x814e690 <main>, argc=3, 
    argv=0xbffff84c, init=0x8049088 <_init>, fini=0x839474c <_fini>, 
    rtld_fini=0x4000aa20 <_dl_fini>, stack_end=0xbffff844)
    at ../sysdeps/generic/libc-start.c:92
>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the Gcc-prs mailing list