typedef, class template and inheritance
Gabriel Dos Reis
Gabriel.Dos-Reis@dptmaths.ens-cachan.fr
Thu Oct 2 18:08:00 GMT 1997
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
More information about the Gcc-bugs
mailing list