the following compiled fine on gcc-3.4.6 but gives error on gcc-4.1.2 error: prototype for 'typename A<T>::B::type A<T>::B::f()' does not match any in class 'A<T>::B' error: candidate is: typename A<T>::type A<T>::B::f() error: template definition of non-template 'typename A<T>::B::type A<T>::B::f()'
template < typename T > class A { typedef int type; class B; }; template < typename T > class A<T>::B { typedef typename A<T>::type type; type g() { return 0;} type f(); }; template < typename T > typename A<T>::B::type A<T>::B::f() { return 0; } ( I have no vanilla gcc available, so hopefully gentoo guys did not screw up gcc-4.1.2 ) Using built-in specs. Target: i686-pc-linux-gnu Configured with: /home/portage/portage/sys-devel/gcc-4.1.2/work/gcc-4.1.2/configure --prefix=/usr --bindir=/usr/i686-pc-linux-gnu/gcc-bin/4.1.2 --includedir=/usr/lib/gcc/i686-pc-linux-gnu/4.1.2/include --datadir=/usr/share/gcc-data/i686-pc-linux-gnu/4.1.2 --mandir=/usr/share/gcc-data/i686-pc-linux-gnu/4.1.2/man --infodir=/usr/share/gcc-data/i686-pc-linux-gnu/4.1.2/info --with-gxx-include-dir=/usr/lib/gcc/i686-pc-linux-gnu/4.1.2/include/g++-v4 --host=i686-pc-linux-gnu --build=i686-pc-linux-gnu --disable-altivec --enable-nls --without-included-gettext --with-system-zlib --disable-checking --disable-werror --enable-secureplt --disable-libunwind-exceptions --disable-multilib --disable-libmudflap --disable-libssp --disable-libgcj --enable-languages=c,c++,fortran --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu Thread model: posix gcc version 4.1.2 (Gentoo 4.1.2) -- Summary: [4.1.2 Regression] templates and typedefs cause function prototype not to match Product: gcc Version: 4.1.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: sschunck at pdf dot de GCC host triplet: i686-pc-linux http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30821