This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
typedef, class template and inheritance
- To: egcs-bugs at cygnus dot com
- Subject: typedef, class template and inheritance
- From: Gabriel Dos Reis <Gabriel dot Dos-Reis at dptmaths dot ens-cachan dot fr>
- Date: Fri, 3 Oct 1997 03:06:22 +0200 (MET DST)
egcs-970929 failed to compile the code below:
% cat toto.C
template <class T, class U> struct foo {
typedef U fred_t;
fred_t foobar() {}
};
template <class T> struct bar : public foo<T, T> {
fred_t foobar();
};
template <class T> bar<T>::fred_t bar<T>::foobar() { return fred_t(); }
% g++ -c toto.C
toto.C:13: new declaration `T bar<T>::foobar()'
toto.C:10: ambiguates old declaration `typename foo<T,T>::fred_t bar<T>::foobar()'
Adding
typedef foo<T, T>::fred_t fred_t;
to the class definition of bar get think fine. gcc shouldn't flag the
former code not legal. Should it ?
-- Gaby