Here is the testcase: template<typename T> struct A { A() {} };
struct B { B() {} A<B> foo(); }; template<typename T> A<T> T::foo() { return A<T>(); } template class A<B>; And the command line: > g++ -c test.cc -Wall test.cc:13: internal compiler error: in is_ancestor, at cp/name-lookup.c:2236 Please submit a full bug report, with preprocessed source if appropriate. See <URL:http://bugs.opensuse.org> for instructions. > g++ -v Using built-in specs. Target: x86_64-suse-linux Configured with: ../configure --enable-threads=posix --prefix=/usr --with-local-prefix=/usr/local --infodir=/usr/share/info --mandir=/usr/share/man --libdir=/usr/lib64 --libexecdir=/usr/lib64 --enable-languages=c,c++,objc,fortran,obj-c++,java,ada --enable-checking=release --with-gxx-include-dir=/usr/include/c++/4.1.2 --enable-ssp --disable-libssp --disable-libgcj --with-slibdir=/lib64 --with-system-zlib --enable-shared --enable-__cxa_atexit --enable-libstdcxx-allocator=new --program-suffix= --enable-version-specific-runtime-libs --without-system-libunwind --with-cpu=generic --host=x86_64-suse-linux Thread model: posix gcc version 4.1.2 20070115 (prerelease) (SUSE Linux) > cat /etc/SuSE-release SUSE Linux Enterprise Server 10 (x86_64) VERSION = 10 PATCHLEVEL = 1 -- Summary: internal compiler error in is_ancestor, at cp/name- lookup.c Product: gcc Version: 4.1.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: thomasd57 at yahoo dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42563