Following snippet causes compiler to produce internal compiler error: typedef void F(void); template <typename T> struct S { static F f; }; template class S<int>; template <class T> void S<T>::f(void) {} I'm not sure it is valid to define S<T>::f() after instantiating the class, but even if not, an ICE is not a proper response for a compiler in any case. #24511 mentions that all member templates (template members?) must be defined before explicit instantiation although I don't read that per se in my copy of the standard. There might be a vague relation to #24791 if there is g++-internal confusion about f being a static data member. This confusion might be exhibited in #33972 as well. Ciao. Vincent.
$g++ -o crash.o crash.cpp + /usr/bin/g++-4.3 -L/home/vincent/lib32 -o crash.o crash.cpp crash.cpp: In static member function ‘static void S<T>::f() [with T = int]’: crash.cpp:6: instantiated from here crash.cpp:4: internal compiler error: Segmentation fault Please submit a full bug report, with preprocessed source if appropriate. See <file:///usr/share/doc/gcc-4.3/README.Bugs> for instructions. $g++ -v + /usr/bin/g++-4.3 -L/home/vincent/lib32 -v Using built-in specs. Target: x86_64-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Debian 4.3.1-2' --with-bugurl=file:///usr/share/doc/gcc-4.3/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --enable-shared --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --enable-nls --with-gxx-include-dir=/usr/include/c++/4.3 --program-suffix=-4.3 --enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --enable-mpfr --enable-cld --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu Thread model: posix gcc version 4.3.1 (Debian 4.3.1-2) $
It compiled with 4.0.1.
original testcase ICEs 4.3.2 also fang% g++-4 -v Using built-in specs. Target: powerpc-apple-darwin8 Configured with: ../gcc-4.3.2/configure --prefix=/sw --prefix=/sw/lib/gcc4.3 --mandir=/sw/share/man --infodir=/sw/share/info --enable-languages=c,c++,fortran,objc,java --build=powerpc-apple-darwin8 --with-gmp=/sw --with-libiconv-prefix=/sw --with-system-zlib --x-includes=/usr/X11R6/include --x-libraries=/usr/X11R6/lib --disable-libjava-multilib Thread model: posix gcc version 4.3.2 (GCC) fang% g++-4 -ansi -pedantic-errors -c temp.cc -o temp.o temp.cc: In static member function 'static void S<T>::f() [with T = int]': temp.cc:6: instantiated from here temp.cc:4: internal compiler error: Bus error Please submit a full bug report, with preprocessed source if appropriate. See <http://gcc.gnu.org/bugs.html> for instruction
Confirmed.
Are we really sure this is invalid? For one, EDG doesn't agree...
Closing 4.2 branch.
GCC 4.3.4 is being released, adjusting target milestone.
Subject: Bug 37037 Author: jason Date: Thu Nov 12 22:49:59 2009 New Revision: 154131 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=154131 Log: PR c++/37037 * decl.c (grokdeclarator): Don't generate a void PARM_DECL. Added: trunk/gcc/testsuite/g++.dg/template/typedef21.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/decl.c trunk/gcc/testsuite/ChangeLog
Subject: Bug 37037 Author: jason Date: Thu Nov 12 23:21:55 2009 New Revision: 154134 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=154134 Log: PR c++/37037 * decl.c (grokdeclarator): Don't generate a void PARM_DECL. Added: branches/gcc-4_4-branch/gcc/testsuite/g++.dg/template/typedef21.C Modified: branches/gcc-4_4-branch/gcc/cp/ChangeLog branches/gcc-4_4-branch/gcc/cp/decl.c branches/gcc-4_4-branch/gcc/testsuite/ChangeLog
Subject: Bug 37037 Author: jason Date: Thu Nov 12 23:22:10 2009 New Revision: 154135 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=154135 Log: PR c++/37037 * decl.c (grokdeclarator): Don't generate a void PARM_DECL. Added: branches/gcc-4_3-branch/gcc/testsuite/g++.dg/template/typedef21.C Modified: branches/gcc-4_3-branch/gcc/cp/ChangeLog branches/gcc-4_3-branch/gcc/cp/decl.c branches/gcc-4_3-branch/gcc/testsuite/ChangeLog
Fixed.