c++/8143: g++ gives an ice

Reichelt reichelt@igpm.rwth-aachen.de
Thu Oct 10 14:35:00 GMT 2002


Hi,

the parser chokes on the following illegal code snippet (X is
undefined):

---------------------------snip here---------------------------
struct foo
{
    X x;

    foo(X)              {}
    foo(X y, int) : x() {}
};
---------------------------snip here---------------------------

The error messages with gcc 3.1 are:

bug.cc:3: 'X' is used as a type, but is not defined as a type.
bug.cc:5: parse error before `)' token
bug.cc:5: missing ';' before right brace
bug.cc:6: `X' was not declared in this scope
bug.cc:6: parse error before `,' token
bug.cc:6: ISO C++ forbids defining types within return type
bug.cc:6: semicolon missing after declaration of `struct foo'
bug.cc: In function `int foo(...)':
bug.cc:6: only constructors take base initializers
bug.cc:6: confused by earlier errors, bailing out

Gcc 2.95.x and 3.0.x handle the situation gracefully. Gcc 3.1 and 3.2
produce "confused by earlier errors, bailing out" and the main trunk
ICEs (checked on i686-pc-linux-gnu and mips-sgi-irix6.5).

Greetings,
Volker Reichelt

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=8143




More information about the Gcc-bugs mailing list