Bug with const int, typedef and templates
Laurent Bonnaud
bonnaud@irisa.fr
Mon Mar 16 08:22:00 GMT 1998
Hi,
i think this is a bug in egcs (tested on version 980221) :
typedef const int cint;
template<class T>
class A
{
public:
T f(cint i);
};
template <class T>
T A<T>::f(cint i)
{
}
int main()
{
A<int> a;
}
% g++ e.cpp
e.cpp:12: prototype for `T A<T>::f(int)' does not match any in class `A<T>'
e.cpp:7: candidate is: T A<T>::f(const int)
e.cpp: In method `T A<T>::f(int)':
e.cpp:12: template definition of non-template `T A<T>::f(int)'
Note how the error message is inconsistent : it refers to
`T A<T>::f(int)' instead of `T A<T>::f(const int)'.
If i replace 'cint' with 'const int' (i.e. i do not use a typedef),
then the program compiles. I could not reproduce the same problem on a
non template class either.
--
Laurent.
More information about the Gcc-bugs
mailing list