Article View: gnu.g++.bug
Article #828g++ crashes when compiling destructor of nested class
From: Scott Kohn
Date: Wed, 19 Aug 1992 20:56
Date: Wed, 19 Aug 1992 20:56
71 lines
3252 bytes
3252 bytes
There is a bug in gcc-2.2.2 which causes cc1plus to dump core when
compiling the destructor of a nested class:
------------------------------ crash.c ------------------------------
class X
{
class Y
{
public:
Y();
~Y();
};
public:
X();
~X();
};
X::Y::Y() { } // this is ok
X::Y::~Y() { } // this is not
---------------------------------------------------------------------
picard [380]% g++ -v -c crash.c
Reading specs from /cse/grad/skohn/lib/gcc-lib/sparc-sun-sunos4.1/2.2.2/specs
gcc version 2.2.2
/cse/grad/skohn/lib/gcc-lib/sparc-sun-sunos4.1/2.2.2/cpp -lang-c++ -v -undef -D__GNUC__=2 -D__GNUG__=2 -D__cplusplus -Dsparc -Dsun -Dunix -D__sparc__ -D__sun__ -D__unix__ -D__sparc -D__sun -D__unix crash.c /usr/tmp/cca08633.i
GNU CPP version 2.2.2 (sparc)
/cse/grad/skohn/lib/gcc-lib/sparc-sun-sunos4.1/2.2.2/cc1plus /usr/tmp/cca08633.i -quiet -dumpbase crash.cc -version -o /usr/tmp/cca08633.s
GNU C++ version 2.2.2 (sparc) compiled by GNU C version 2.2.2.
/cse/grad/skohn/bin/gcc: Internal compiler error: program cc1plus got fatal signal 11
picard [381]% gdb /cse/grad/skohn/lib/gcc-lib/sparc-sun-sunos4.1/2.2.2/cc1plus
(gdb) core-file core
Core was generated by `cc1plus'.
Program terminated with signal 11, Segmentation fault.
#0 build_overload_name (parmtypes=0x0, begin=1, end=1) at cp-method.c:1572
1572 if (just_one = (TREE_CODE (parmtypes) != TREE_LIST))
(gdb) where
#0 build_overload_name (parmtypes=0x0, begin=1, end=1) at cp-method.c:1572
#1 0x27598 in grokclassfn (ctype=0x186418, cname=0x1863b8, function=0x18e008,
flags=DTOR_FLAG, quals=0x17f7a8) at cp-decl2.c:627
#2 0x1cf2c in grokfndecl (ctype=0x186418, type=0x186888, declarator=0x1863b8, virtualp=0,
flags=DTOR_FLAG, quals=0x0, raises=0x0, check=1) at cp-decl.c:5954
#3 0x219ac in grokdeclarator (declarator=0x1863b8, declspecs=0x0, decl_context=NORMAL,
initialized=1, raises=0x0) at cp-decl.c:7987
#4 0x23a5c in start_function (declspecs=0x0, declarator=0x174e48, raises=0x0, pre_parsed_p=0)
at cp-decl.c:9239
#5 0xe628 in yyparse () at cp-parse.y:635
#6 0x7aca8 in compile_file (name=0xf7fffa99 "/usr/tmp/cca08633.i") at toplev.c:1638
#7 0x7d88c in main (argc=8, argv=0xf7fff9d4, envp=0xf7fff9f8) at toplev.c:3055
Note that it is ok to define the destructor of the nested class in the declaration.
Thus, you can get around this bug using the following (yuck):
------------------------------ ugly.c ------------------------------
class X
{
class Y
{
void destructor_hack();
public:
Y();
inline ~Y() { destructor_hack(); }
};
public:
X();
~X();
};
X::Y::Y() { }
void X::Y::destructor_hack() { }
--------------------------------------------------------------------
Technical Details
Message-ID:
<9208192056.AA08654@picard.ucsd.edu>Path:
arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!cs.ucsd.edu!skohnShow Full Headers
Complete Article Headers
Newsgroups: gnu.g++.bug Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!cs.ucsd.edu!skohn From: skohn@cs.ucsd.edu (Scott Kohn) Subject: g++ crashes when compiling destructor of nested class Message-ID: <9208192056.AA08654@picard.ucsd.edu> Sender: gnulists@ai.mit.edu Organization: GNUs Not Usenet Distribution: gnu Date: Wed, 19 Aug 1992 20:56:51 GMT Approved: bug-g++@prep.ai.mit.edu Lines: 72