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)
EDG happily eats this. With mainline the error looks like t.ii:18: error: prototype for ‘typename A<T>::B::type A<T>::B::f()’ does not match any in class ‘A<T>::B’ t.ii:13: error: candidate is: typename A<T>::type A<T>::B::f() t.ii:18: error: ‘typename A<T>::B::type A<T>::B::f()’ cannot be overloaded t.ii:13: error: with ‘typename A<T>::type A<T>::B::f()’ t.ii:18: error: template definition of non-template ‘typename A<T>::B::type A<T>::B::f()’
*** Bug 30821 has been marked as a duplicate of this bug. ***
A regression hunt on powerpc-linux identified this mainline patch: http://gcc.gnu.org/viewcvs?view=rev&rev=116409 r116409 | nathan | 2006-08-25 09:56:07 -0700 (Fri, 25 Aug 2006) This patch was backported to the 4.1 branch on 2006-10-18.
testing a patch
Subject: Bug 30818 Author: nathan Date: Sun Jul 22 16:25:54 2007 New Revision: 126825 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=126825 Log: cp/ PR c++/30818 * typeck.c (structural_comptypes): No need to check resolve_typename_type return value here. * cp-tree.h (TYPENAME_IS_RESOLVING_P): New. * pt.c (resolve_typename_type): Follow typename typedefs. Return original type rather than error_mark_node in case of failure. * parser.c (cp_parser_nested_name_specifier_opt): Adjust resolve_typename_type result check. (cp_parser_direct_declarator, cp_parser_head, cp_parser_constructor_declarator_p): Likewise. testsuite/ PR c++/30818 * g++.dg/template/crash47.C: Adjust errors. * g++.dg/template/crash48.C: Adjust errors. * g++.dg/template/typename12.C: New. * g++.dg/template/typename13.C: New. * g++.dg/template/typename14.C: New. * g++.dg/template/typedef6.C: Adjust errors. Added: trunk/gcc/testsuite/g++.dg/template/typename12.C trunk/gcc/testsuite/g++.dg/template/typename13.C trunk/gcc/testsuite/g++.dg/template/typename14.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/cp-tree.h trunk/gcc/cp/parser.c trunk/gcc/cp/pt.c trunk/gcc/cp/typeck.c trunk/gcc/testsuite/ChangeLog trunk/gcc/testsuite/g++.dg/template/crash47.C trunk/gcc/testsuite/g++.dg/template/crash48.C trunk/gcc/testsuite/g++.dg/template/typedef6.C
fixed with http://gcc.gnu.org/ml/gcc-patches/2007-07/msg01644.html cp/ PR c++/30818 * typeck.c (structural_comptypes): No need to check resolve_typename_type return value here. * cp-tree.h (TYPENAME_IS_RESOLVING_P): New. * pt.c (resolve_typename_type): Follow typename typedefs. Return original type rather than error_mark_node in case of failure. * parser.c (cp_parser_nested_name_specifier_opt): Adjust resolve_typename_type result check. (cp_parser_direct_declarator, cp_parser_head, cp_parser_constructor_declarator_p): Likewise. testsuite/ PR c++/30818 * g++.dg/template/crash47.C: Adjust errors. * g++.dg/template/crash48.C: Adjust errors. * g++.dg/template/typename12.C: New. * g++.dg/template/typename13.C: New. * g++.dg/template/typename14.C: New. * g++.dg/template/typedef6.C: Adjust errors. the patch should backport painlessly to 4.2
Re-open, as the branches are still affected and this is a regression.
Closing 4.1 branch.
Closing 4.2 branch, fixed in 4.3.