Template bug?

Alexandre Oliva oliva@dcc.unicamp.br
Tue Sep 8 23:43:00 GMT 1998


Knut Akesson <ka@s2.chalmers.se> writes:

> I might have found a bug in the egcs-1.1 compiler. I got this error
> message :

>> test.cpp: In method `class T<double>::A S<double,char>::foo<double, char>()':
>> test.cpp:37:   instantiated from here
>> test.cpp:32: conversion from `T<char>' to non-scalar type `T<double>::A' requested
>> test.cpp: In function `int main(...)':
>> test.cpp:37: conversion from `T<double>::A' to non-scalar type `T<char>::A' requested     

The error message is misleading, but the problem is quite easy to
fix.  Just insert `typename' before the template-dependent type name
`T<C>::A', and you should be done:

    typename \
>   T<C>::A foo() { return T<C>(); }

-- 
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