From: adams@cs.wisc.edu (Paul Adams)
Subject: g++ 2.2.2 crashes after parse error
Organization: GNUs Not Usenet
Distribution: gnu
Date: Thu, 27 Aug 1992 20:45:33 GMT

Hi.  Below is an example program that causes g++ to crash if a parse error
is found in a method whose body is inside a class declaration.  Defining the 
erroneous method outside the class works fine (ie the bug is reported, but no 
crash).


Paul Adams
Department of Computer Sciences
1210 W. Dayton St
Madison, Wisconsin 53706
adams@cs.wisc.edu

-------------------------------------------------------------------------------
Script started on Thu Aug 27 15:29:59 1992
adams 21>cat bug1.c

/* 
Parse error in in-line definition of method causes g++ to crash;
same error in separate method definition does not
*/

#ifndef NOBUG

class C {
public:
	virtual void g(int t)
		{
			if t==1 return;
			else {
				int r= t;
			}
		}
};

#else

class C {
public:
	virtual void g(int t);
};

void C::g(int t)
{
	if t==1 return;
	else {
		int r= t;
	}
}

#endif
adams 22>g++ -c -v bug1.c
Reading specs from /usr/gnu/lib/gcc-lib/decstation/2.2.2/specs
gcc version 2.2.2
 /usr/gnu/lib/gcc-lib/decstation/2.2.2/cpp -lang-c++ -v -undef -D__GNUC__=2 -D__GNUG__=2 -D__cplusplus -D__ANSI_COMPAT -DMIPSEL -DR3000 -DSYSTYPE_BSD -D_SYSTYPE_BSD -Dbsd4_2 -Dhost_mips -Dmips -Dultrix -Dunix -D__ANSI_COMPAT -D__MIPSEL__ -D__R3000__ -D__SYSTYPE_BSD__ -D___SYSTYPE_BSD__ -D__bsd4_2__ -D__host_mips__ -D__mips__ -D__ultrix__ -D__unix__ -D__ANSI_COMPAT -D__MIPSEL -D__R3000 -D__SYSTYPE_BSD -D___SYSTYPE_BSD -D__bsd4_2 -D__host_mips -D__mips -D__ultrix -D__unix -D__LANGUAGE_C__ -D__LANGUAGE_C -DLA
NGUAGE_C bug1.c /usr/tmp/cca03784.i
GNU CPP version 2.2.2 [AL 1.1, MM 19] DECstation running ultrix
 /usr/gnu/lib/gcc-lib/decstation/2.2.2/cc1plus /usr/tmp/cca03784.i -quiet -dumpbase bug1.cc -version -o /usr/tmp/cca03784.s
GNU C++ version 2.2.2 [AL 1.1, MM 19] DECstation running ultrix compiled by GNU C version 2.2.2.
bug1.c: In method `void  C::g (int)':
bug1.c:13: parse error before `=='
bug1.c: At top level:
bug1.c:17: parse error at end of saved function text
/usr/gnu/bin/gcc: Internal compiler error: program cc1plus got fatal signal 11
adams 23>
adams 23>g++ -c -v -DNOBUG bug1.c
Reading specs from /usr/gnu/lib/gcc-lib/decstation/2.2.2/specs
gcc version 2.2.2
 /usr/gnu/lib/gcc-lib/decstation/2.2.2/cpp -lang-c++ -v -DNOBUG -undef -D__GNUC__=2 -D__GNUG__=2 -D__cplusplus -D__ANSI_COMPAT -DMIPSEL -DR3000 -DSYSTYPE_BSD -D_SYSTYPE_BSD -Dbsd4_2 -Dhost_mips -Dmips -Dultrix -Dunix -D__ANSI_COMPAT -D__MIPSEL__ -D__R3000__ -D__SYSTYPE_BSD__ -D___SYSTYPE_BSD__ -D__bsd4_2__ -D__host_mips__ -D__mips__ -D__ultrix__ -D__unix__ -D__ANSI_COMPAT -D__MIPSEL -D__R3000 -D__SYSTYPE_BSD -D___SYSTYPE_BSD -D__bsd4_2 -D__host_mips -D__mips -D__ultrix -D__unix -D__LANGUAGE_C__ -D__LANGUAG
E_C -DLANGUAGE_C bug1.c /usr/tmp/cca03796.i
GNU CPP version 2.2.2 [AL 1.1, MM 19] DECstation running ultrix
 /usr/gnu/lib/gcc-lib/decstation/2.2.2/cc1plus /usr/tmp/cca03796.i -quiet -dumpbase bug1.cc -version -o /usr/tmp/cca03796.s
GNU C++ version 2.2.2 [AL 1.1, MM 19] DECstation running ultrix compiled by GNU C version 2.2.2.
bug1.c: In method `void  C::g (int)':
bug1.c:29: parse error before `=='
adams 24>exit
exit

script done on Thu Aug 27 15:30:50 1992

Newsgroups: gnu.g++.bug