This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: possible empty struct bug in egcs 1.1
- To: "Mark E." <snowball3 at usa dot net>
- Subject: Re: possible empty struct bug in egcs 1.1
- From: Alexandre Oliva <oliva at dcc dot unicamp dot br>
- Date: 09 Sep 1998 00:38:53 z
- Cc: egcs-bugs at cygnus dot com
- References: <199809060451.EAA56472@out1.ibm.net>
Mark E <snowball3@usa.net> writes:
> I'm wondering if I've found a bug in the egcs 1.1 compiler.
You did
> typedef container_class<X> container;
> typedef typename container::foo foo;
> foo _f;
> container _c(foo(), _val); // parse error here
I don't get a parse error with egcs 1.1; I get:
test.cc: In function `void some_func(X)':
test.cc:23: type specifier omitted for parameter
Anyway, egcs is incorrectly solving an ambiguity that exists in the
C++ grammar. Up to the point `container _c(foo(),', it looks like _c
is a declaration of a function that returns a container, and takes, as
its first argument, a pointer to a function that takes no arguments
and returns a foo. However, when the compiler reaches `_val', it
should reinterpret the whole sequence of tokens as a definition with
direct initialization of an object `_c' of type `container', because
`_val' is an expression, rather than a type name.
> but if I change it to:
> container _c(_f, _val);
> Then the error goes away.
Sure; there's no ambiguity left, because `_f' is not a type name
either.
--
Alexandre Oliva
mailto:oliva@dcc.unicamp.br mailto:aoliva@acm.org
http://www.dcc.unicamp.br/~oliva
Universidade Estadual de Campinas, SP, Brasil