This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Questionable 1.1 C++ parsing


Phil Blecker <tmwg@inxservices.com> writes:

> I expected the lines constructing n and i to be parsed the same in the
> attached files

Your expectations are correct, in this case.  There's an ambiguity in
the C++ grammar, and egcs will sometimes incorrectly decide how to
solve the ambiguity.  For example, if N were the name of a type, the
following declaration:

> 	const int i(int(sqrt(N())));

would be equivalent to:

        const int i(int sqrt(N (*)()));

But the egcs bug is still worse, since i is declared as a function
that takes an empty argument list.  It seems that `int(sqrt(N()))' is
being interpreted as a top-level declaration of a variable named sqrt,
initialized with N.  This can be verified with -Wall: it says that
variable `sqrt' is unused.

A real bug, indeed :-(

Jason, may I install the attached test case in g++.other?

-- 
Alexandre Oliva
mailto:oliva@dcc.unicamp.br mailto:aoliva@acm.org
http://www.dcc.unicamp.br/~oliva
Universidade Estadual de Campinas, SP, Brasil

decl1.C


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]