gcc generates misleading error message

Martin v. Loewis martin@mira.isdn.cs.tu-berlin.de
Sun Oct 31 23:03:00 GMT 1999


> Now, of course, in the trivial test case I give here, it doesn't much
> matter that the error message is misleading; it's obvious what the
> problem is.  But I encountered this same message in a real program,
> and it took me half an hour of scratching my head before I realized
> that the problem wasn't syntactic at all, but rather a simple failure
> to define a data type.

Unfortunately, this is hard to fix, because in gcc, this *is* a
syntactic error: The C language distinguishes between type names and
other identifiers on a syntactic level. So it is indeed the
syntactical analysis that expects a TYPENAME token in some place, and
gives a syntax error when there is none.

The traditional "solution" is that GCC users get accustomed to that
pitfall: that a syntax error could also indicate that a type was not
defined or misspelled.

Hopefully, somebody will rewrite the parser some day so that this gets
fixed as well.

Regards,
Martin



More information about the Gcc-bugs mailing list