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: Template bug?


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



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