>g++ -v -save-temps -c test.cpp Reading specs from d:/gcc/bin/../lib/gcc-lib/mingw32/3.3.1/specs Configured with: ../gcc/configure --with-gcc --with-gnu-ld --with-gnu-as --host= mingw32 --target=mingw32 --prefix=/mingw --enable-threads --disable-nls --enable -languages=c,c++,f77,objc,ada,java --disable-win32-registry --disable-shared --e nable-sjlj-exceptions --enable-libgcj --disable-java-awt --without-x --enable-ja va-gc=boehm --disable-libgcj-debug --enable-interpreter --enable-hash-synchroniz ation Thread model: win32 gcc version 3.3.1 (mingw special 20030804-1) d:\gcc\bin\..\lib\gcc-lib\mingw32\3.3.1\cc1plus.exe -E -D__GNUG__=3 -quiet -v - iprefix d:\gcc\bin/../lib/gcc-lib/mingw32/3.3.1/ -D__GNUC__=3 -D__GNUC_MINOR__=3 -D__GNUC_PATCHLEVEL__=1 test.cpp test.ii ignoring nonexistent directory "d:/gcc/mingw32/include" ignoring nonexistent directory "/mingw/include/c++/3.3.1" ignoring nonexistent directory "/mingw/include/c++/3.3.1/mingw32" ignoring nonexistent directory "/mingw/include/c++/3.3.1/backward" ignoring nonexistent directory "/mingw/include" ignoring nonexistent directory "/mingw/include" ignoring nonexistent directory "/mingw/lib/gcc-lib/mingw32/3.3.1/include" ignoring nonexistent directory "/mingw/mingw32/include" ignoring nonexistent directory "/mingw/include" #include "..." search starts here: #include <...> search starts here: d:/gcc/include/c++/3.3.1 d:/gcc/include/c++/3.3.1/mingw32 d:/gcc/include/c++/3.3.1/backward d:/gcc/include d:/gcc/lib/gcc-lib/mingw32/3.3.1/include End of search list. d:\gcc\bin\..\lib\gcc-lib\mingw32\3.3.1\cc1plus.exe -fpreprocessed test.ii -qui et -dumpbase test.cpp -auxbase test -version -o test.s GNU C++ version 3.3.1 (mingw special 20030804-1) (mingw32) compiled by GNU C version 3.3.1 20030803 (prerelease). GGC heuristics: --param ggc-min-expand=64 --param ggc-min-heapsize=65476 test.cpp: In static member function `static void A<T>::error() [with T = B]': test.cpp:19: instantiated from here test.cpp:11: internal compiler error: in cxx_incomplete_type_diagnostic, at cp/typeck2.c:282 Please submit a full bug report, with preprocessed source if appropriate. See <URL:http://www.mingw.org/bugs.shtml> for instructions. Preprocessed file: # 1 "test.cpp" # 1 "<built-in>" # 1 "<command line>" # 1 "test.cpp" # 1 "d:/gcc/include/c++/3.3.1/typeinfo" 1 3 # 38 "d:/gcc/include/c++/3.3.1/typeinfo" 3 # 1 "d:/gcc/include/c++/3.3.1/exception" 1 3 # 40 "d:/gcc/include/c++/3.3.1/exception" 3 extern "C++" { namespace std { # 52 "d:/gcc/include/c++/3.3.1/exception" 3 class exception { public: exception() throw() { } virtual ~exception() throw(); virtual const char* what() const throw(); }; class bad_exception : public exception { public: bad_exception() throw() { } virtual ~bad_exception() throw(); }; typedef void (*terminate_handler) (); typedef void (*unexpected_handler) (); terminate_handler set_terminate(terminate_handler) throw(); void terminate() __attribute__ ((__noreturn__)); unexpected_handler set_unexpected(unexpected_handler) throw(); void unexpected() __attribute__ ((__noreturn__)); # 100 "d:/gcc/include/c++/3.3.1/exception" 3 bool uncaught_exception() throw(); } namespace __gnu_cxx { # 113 "d:/gcc/include/c++/3.3.1/exception" 3 void __verbose_terminate_handler (); } } # 39 "d:/gcc/include/c++/3.3.1/typeinfo" 2 3 extern "C++" { namespace __cxxabiv1 { class __class_type_info; } # 55 "d:/gcc/include/c++/3.3.1/typeinfo" 3 namespace std { class type_info { public: virtual ~type_info(); private: type_info& operator=(const type_info&); type_info(const type_info&); protected: const char *__name; protected: explicit type_info(const char *__n): __name(__n) { } public: const char* name() const { return __name; } bool before(const type_info& __arg) const; bool operator==(const type_info& __arg) const; # 106 "d:/gcc/include/c++/3.3.1/typeinfo" 3 bool operator!=(const type_info& __arg) const { return !operator==(__arg); } public: virtual bool __is_pointer_p() const; virtual bool __is_function_p() const; virtual bool __do_catch(const type_info *__thr_type, void **__thr_obj, unsigned __outer) const; virtual bool __do_upcast(const __cxxabiv1::__class_type_info *__target, void **__obj_ptr) const; }; class bad_cast : public exception { public: bad_cast() throw() { } virtual ~bad_cast() throw(); }; class bad_typeid : public exception { public: bad_typeid () throw() { } virtual ~bad_typeid() throw(); }; } } # 2 "test.cpp" 2 template < template <class> class T > struct A { static void error() { const char * name = typeid(T).name(); } }; template <class T> struct B {}; int main(int argc, char **argv) { A<B>::error(); return 0; }
Confirmed with gcc 2.96, 3.2 and 3.3, but already fixed in mainline. The code in question is --------------------------- #include <typeinfo> template <template <class> class T> struct A { void error() { typeid(T).name(); } }; template <class T> struct B {}; template void A<B>::error(); ------------------------------------------- which of course is invalid since T in typeid(T) is not a type but a template. Present mainline gives the following error message: tmp/g> ../build-gcc/gcc-install/bin/c++ -c x.cc x.cc: In member function `void A<T>::error()': x.cc:6: error: missing template arguments W.
Actually this is a regression with respect to 2.95.3 so reopening.
From 2.95.3, I get: tin:~/src/gnu/gcctest>~/ia32_linux_gcc2_95/bin/gcc pr11991.cc pr11991.cc: In method `void A<B>::error()': pr11991.cc:11: instantiated from here pr11991.cc:5: taking typeid of incomplete type `T'
The new parser fixed this regression so maybe this will not be fixed for 3.3.x.
This is certainly low priority: it's an ice-on-invalid, and the old error message wasn't quite accurate either. There are certainly more important bugs to be fixed on the release branch. W.
Subject: Bug 11991 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-3_3-branch Changes by: mmitchel@gcc.gnu.org 2003-09-17 23:48:27 Modified files: gcc/cp : ChangeLog call.c class.c cp-tree.h typeck2.c gcc/testsuite : ChangeLog Added files: gcc/testsuite/g++.dg/abi: bitfield11.C bitfield12.C gcc/testsuite/g++.dg/overload: template1.C gcc/testsuite/g++.dg/rtti: typeid3.C Log message: PR c++/11991 * typeck2.c (incomplete_type_diagnostic): Robustify. PR c++/11991 * g++.dg/rtti/typeid3.C: New test. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.3076.2.207&r2=1.3076.2.208 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/call.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.341.2.32&r2=1.341.2.33 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/class.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.499.2.21&r2=1.499.2.22 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/cp-tree.h.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.776.2.33&r2=1.776.2.34 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/typeck2.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.132.4.3&r2=1.132.4.4 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.2261.2.281&r2=1.2261.2.282 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/abi/bitfield11.C.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=NONE&r2=1.1.2.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/abi/bitfield12.C.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=NONE&r2=1.1.2.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/overload/template1.C.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=NONE&r2=1.1.2.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/rtti/typeid3.C.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=NONE&r2=1.1.2.1
Subject: Bug 11991 CVSROOT: /cvs/gcc Module name: gcc Changes by: mmitchel@gcc.gnu.org 2003-09-17 23:50:05 Modified files: gcc/testsuite : ChangeLog Added files: gcc/testsuite/g++.dg/rtti: typeid3.C Log message: PR c++/11991 * g++.dg/rtti/typeid3.C: New test. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.3061&r2=1.3062 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/rtti/typeid3.C.diff?cvsroot=gcc&r1=1.1&r2=1.2
Fixed in GCC 3.3.2.