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]

Bug with const int, typedef and templates



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.


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