gcc 2.95.2 bug report: Templates

Alexandre Oliva oliva@lsd.ic.unicamp.br
Sun Feb 13 09:53:00 GMT 2000


On Feb 13, 2000, "Robert C. Paulsen, Jr." <paulsen@texas.net> wrote:

> template<class T>
> void func( T ctr ) {
>    T::iterator i;             // this fails with "parse error before ';'"

The C++ Standard requires that template-dependent type names must be
preceded by the keyword `typename'.  Try:

     typename T::iterator i;

Please note that GCC *sometimes* parses such contructs as you could
expect, even when the `typename' keyword is missing.  But this is an
extension, that can't always be implemented, and that is disabled if
you compile with -pedantic.

-- 
Alexandre Oliva     http://www.ic.unicamp.br/~oliva/     Enjoy Guaraná
Cygnus Solutions, a Red Hat company        aoliva@{redhat, cygnus}.com
Free Software Developer and Evangelist    CS PhD student at IC-Unicamp
oliva@{lsd.ic.unicamp.br, gnu.org}   Write to mailing lists, not to me



More information about the Gcc-bugs mailing list