This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: Template bug?
- To: Knut Akesson <ka at s2 dot chalmers dot se>
- Subject: Re: Template bug?
- From: Alexandre Oliva <oliva at dcc dot unicamp dot br>
- Date: 09 Sep 1998 00:43:20 z
- Cc: egcs-bugs at cygnus dot com
- References: <35F277C6.B55A755A@s2.chalmers.se>
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