egcs 1.1b: strange syntax error under -pedantic

Alexandre Oliva oliva@dcc.unicamp.br
Mon Sep 28 17:39:00 GMT 1998


Chris Metcalf <metcalf@incert.com> writes:

>   template <class FOO> class A { typedef int a_int; };

>   template <class FOO> class B { typedef A<FOO*> A_FOO;
>     A_FOO::a_int foo; };

>   foo.cpp:7: syntax error before `;'

The error message is correct.  According to the C++ Standard, you must
prefix template-dependent qualified type names with the keyword
`typename'.  Without -pedantic, it is accepted as an extension.  Try:

      typename A_FOO::a_int foo;

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




More information about the Gcc-bugs mailing list