This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Questionable 1.1 C++ parsing
- To: Phil Blecker <tmwg at inxservices dot com>
- Subject: Re: Questionable 1.1 C++ parsing
- From: Alexandre Oliva <oliva at dcc dot unicamp dot br>
- Date: 16 Sep 1998 19:51:45 +-300
- Cc: egcs-bugs at cygnus dot com, egcs-patches at cygnus dot com, jason at cygnus dot com
- References: <19980915165231.B14538@inxservices.com>
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