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: possible empty struct bug in egcs 1.1


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



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