typedef confuses the name of the template and the name of result: sh-3.2$ cat tloop_iterator.h #ifndef TLOOP_ITERATOR_H_ #define TLOOP_ITERATOR_H_ #include <list> template<typename T> struct loop_iterator : public T::iterator { }; template <typename T> struct list : std::list<T> { typedef loop_iterator<list> loop_iterator; }; #endif Compiling this file: sh-3.2$ g++-4.1 tloop_iterator.h sh-3.2$ g++-4.2 tloop_iterator.h all right, but: sh-3.2$ g++-4.3 tloop_iterator.h tloop_iterator.h:14: error: declaration of ‘typedef struct loop_iterator<list<T> > list<T>::loop_iterator’ tloop_iterator.h:8: error: changes meaning of ‘loop_iterator’ from ‘struct loop_iterator<list<T> >’ sh-3.2$ g++-4.3 --version g++-4.3 (Debian 4.3.2-1) 4.3.2 Copyright (C) 2008 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. My system is Debian GLU/Linux Lenny Version 4.3.1 also has this problem
Created attachment 16896 [details] demo
No GCC 4.3 and above is doing the correct thing. This code is invalid but no diagnostic is required by the C++ standard. See <http://gcc.gnu.org/gcc-4.3/porting_to.html>: Name lookup changes GCC by default no longer accepts code such as template <class _Tp> class auto_ptr {}; template <class _Tp> struct counted_ptr { auto_ptr<_Tp> auto_ptr(); }; but will issue the diagnostic error: declaration of 'auto_ptr<_Tp> counted_ptr<_Tp>::auto_ptr()' error: changes meaning of 'auto_ptr' from 'class auto_ptr<_Tp>' The reference to struct auto_ptr needs to be qualified here, or the name of the member function changed to be unambiguous. template <class _Tp> class auto_ptr {}; template <class _Tp> struct counted_ptr { ::auto_ptr<_Tp> auto_ptr(); }; In addition, -fpermissive can be used as a temporary workaround to convert the error into a warning until the code is fixed. Note that then in some case name lookup will not be standard conforming.