Article View: gnu.g++.bug
Article #199GCC 2.1: core dump when class name not declared
From: Gerald Baumgartner
Date: Fri, 10 Apr 1992 05:23
Date: Fri, 10 Apr 1992 05:23
62 lines
2185 bytes
2185 bytes
class ByteSink;
Given the following code:
class OutputStream {
public:
OutputStream( ByteSink & );
};
inline
OutputStream::OutputStream( ByteSink & bs )
{
}
GCC 2.1 produces a
stdin:3: parse error before `&'
in the class declaration. It would be nicer to get an error message
that says that ByteSink is undeclared, but at least the compiler doesn't
die. In the declaration of OutputStream::OutputStream, we get a
better error message
stdin:7: `ByteSink' undeclared, outside of functions
stdin:7: `bs' undeclared, outside of functions
but this time followed by a core dump (abort).
The abort happens in `grokdeclarator' in file cp-decl.c, line 6297.
`grokdeclarator' was called by `start_function'. The code surrounding
the call to `abort' is
if (parmlist_is_random (TREE_OPERAND (decl, 1)))
{
decl = TREE_OPERAND (decl, 0);
if (TREE_CODE (decl) == SCOPE_REF)
{
if (TREE_COMPLEXITY (decl))
-> abort ();
decl = TREE_OPERAND (decl, 1);
}
if (TREE_CODE (decl) == IDENTIFIER_NODE)
name = IDENTIFIER_POINTER (decl);
if (name)
error ("bad parameter list specification for function `%s'",
name);
else
error ("bad parameter list specification for function");
return 0;
}
bot:
According to the code, the problem seems to be that the tree is too complex.
So, let's try to make it less complex; we delete `inline'. The result
is an additional (bogus) error message instead of aborting:
stdin:6: `ByteSink' undeclared, outside of functions
stdin:6: `bs' undeclared, outside of functions
stdin:7: no `OutputStream' member function declared in class
--Gerald
Technical Details
Message-ID:
<18393@ector.cs.purdue.edu>Path:
arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!cs.purdue.edu!gbShow Full Headers
Complete Article Headers
Newsgroups: gnu.g++.bug Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!cs.purdue.edu!gb From: gb@cs.purdue.edu (Gerald Baumgartner) Subject: GCC 2.1: core dump when class name not declared Message-ID: <18393@ector.cs.purdue.edu> Sender: gnulists@ai.mit.edu Organization: Department of Computer Science, Purdue University Distribution: gnu Date: Fri, 10 Apr 1992 05:23:56 GMT Approved: bug-g++@prep.ai.mit.edu Lines: 63