This is GCC Bugzilla
This is GCC Bugzilla Version 2.20+
View Bug Activity | Format For Printing | Clone This Bug
tracked down sample is: $ cat xx.cc template < int I > struct A { int get_val() const; static int val_; }; template< int I > int A<I>::get_val() const { return val_; } template< int I > // this is invalid: works with "template <>" int A<0>::val_(0); // must instantiate to get ICE template class A<0>; $ g++ -v Reading specs from /tools/snapshot/toolsbox-3.5.1.4pre.20051110/bin/../lib/gcc/i686-pc-linux-gnu/3.4.4/specs Configured with: /tools/snapshot/src/sapc154/toolsbox-3.5.1.4pre.20051110/buildroot/gcc/gcc-3.4.4/configure --with-gnu-as --with-gnu-ld --enable-threads=posix --with-as=/tools/snapshot/toolsbox-3.5.1.4pre.20051110//i686-pc-linux-gnu/bin/as --with-ld=/tools/snapshot/toolsbox-3.5.1.4pre.20051110//i686-pc-linux-gnu/bin/ld --with-local-prefix=/tools/snapshot/toolsbox-3.5.1.4pre.20051110/ --disable-nls --prefix=/tools/snapshot/toolsbox-3.5.1.4pre.20051110/ Thread model: posix gcc version 3.4.4 $ g++ -v -c xx.cc Reading specs from /tools/snapshot/toolsbox-3.5.1.4pre.20051110/bin/../lib/gcc/i686-pc-linux-gnu/3.4.4/specs Configured with: /tools/snapshot/src/sapc154/toolsbox-3.5.1.4pre.20051110/buildroot/gcc/gcc-3.4.4/configure --with-gnu-as --with-gnu-ld --enable-threads=posix --with-as=/tools/snapshot/toolsbox-3.5.1.4pre.20051110//i686-pc-linux-gnu/bin/as --with-ld=/tools/snapshot/toolsbox-3.5.1.4pre.20051110//i686-pc-linux-gnu/bin/ld --with-local-prefix=/tools/snapshot/toolsbox-3.5.1.4pre.20051110/ --disable-nls --prefix=/tools/snapshot/toolsbox-3.5.1.4pre.20051110/ Thread model: posix gcc version 3.4.4 /tools/snapshot/toolsbox-3.5.1.4pre.20051110/bin/../libexec/gcc/i686-pc-linux-gnu/3.4.4/cc1plus -quiet -v -iprefix /tools/snapshot/toolsbox-3.5.1.4pre.20051110/bin/../lib/gcc/i686-pc-linux-gnu/3.4.4/ -D_GNU_SOURCE xx.cc -quiet -dumpbase xx.cc -mtune=pentiumpro -auxbase xx -version -o /tmp/ccuQDWYE.s ignoring nonexistent directory "/tools/snapshot/toolsbox-3.5.1.4pre.20051110/bin/../lib/gcc/i686-pc-linux-gnu/3.4.4/../../../../i686-pc-linux-gnu/include" ignoring duplicate directory "/tools/snapshot/toolsbox-3.5.1.4pre.20051110//lib/gcc/i686-pc-linux-gnu/3.4.4/../../../../include/c++/3.4.4" ignoring duplicate directory "/tools/snapshot/toolsbox-3.5.1.4pre.20051110//lib/gcc/i686-pc-linux-gnu/3.4.4/../../../../include/c++/3.4.4/i686-pc-linux-gnu" ignoring duplicate directory "/tools/snapshot/toolsbox-3.5.1.4pre.20051110//lib/gcc/i686-pc-linux-gnu/3.4.4/../../../../include/c++/3.4.4/backward" ignoring duplicate directory "/tools/snapshot/toolsbox-3.5.1.4pre.20051110//lib/gcc/i686-pc-linux-gnu/3.4.4/include" ignoring nonexistent directory "/tools/snapshot/toolsbox-3.5.1.4pre.20051110//lib/gcc/i686-pc-linux-gnu/3.4.4/../../../../i686-pc-linux-gnu/include" #include "..." search starts here: #include <...> search starts here: /tools/snapshot/toolsbox-3.5.1.4pre.20051110/bin/../lib/gcc/i686-pc-linux-gnu/3.4.4/../../../../include/c++/3.4.4 /tools/snapshot/toolsbox-3.5.1.4pre.20051110/bin/../lib/gcc/i686-pc-linux-gnu/3.4.4/../../../../include/c++/3.4.4/i686-pc-linux-gnu /tools/snapshot/toolsbox-3.5.1.4pre.20051110/bin/../lib/gcc/i686-pc-linux-gnu/3.4.4/../../../../include/c++/3.4.4/backward /tools/snapshot/toolsbox-3.5.1.4pre.20051110/bin/../lib/gcc/i686-pc-linux-gnu/3.4.4/include /tools/snapshot/toolsbox-3.5.1.4pre.20051110//include /usr/include End of search list. GNU C++ version 3.4.4 (i686-pc-linux-gnu) compiled by GNU C version 3.4.4. GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 xx.cc:18: internal compiler error: Segmentation fault Please submit a full bug report, with preprocessed source if appropriate. See <URL:http://gcc.gnu.org/bugs.html> for instructions.
Confirmed. The following code snippet causes an ICE since 2.95.3 with the exception of 4.0.0 - 4.0.2: ================================== template<int> struct A { static int i; A() { ++i; } }; template<int> int A<0>::i(0); A<0> a; ================================== The following variation causes an ICE since 4.0.0 (and before 3.1) and is accepted by GCC 3.1 - 3.4.5: ================================== template<int> struct A { static int i; }; template<int> int A<0>::i(0); ==================================
*** Bug 28316 has been marked as a duplicate of this bug. ***
Btw, the ICE for the second testcase in comment #1 happens in instantiate_decl, at cp/pt.c:11875
*** Bug 28897 has been marked as a duplicate of this bug. ***
*** Bug 30234 has been marked as a duplicate of this bug. ***
Comment #3 is not quite correct: The ICE for the first testcase in comment #1 is in instantiate_decl, at cp/pt.c:12204 The ICE for the second testcase in comment #1 is in import_export_decl, at cp/decl2.c:1956
*** Bug 30722 has been marked as a duplicate of this bug. ***
*** Bug 30721 has been marked as a duplicate of this bug. ***
*** Bug 32308 has been marked as a duplicate of this bug. ***
*** Bug 33046 has been marked as a duplicate of this bug. ***
*** Bug 33093 has been marked as a duplicate of this bug. ***
Subject: Bug 24791 Author: jason Date: Fri Oct 26 19:54:10 2007 New Revision: 129660 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=129660 Log: PR c++/24791 * pt.c (get_template_info): New fn. (template_class_depth): Use it. (push_template_decl_real): Check that the template args of the definition match the args of the previous declaration. Added: trunk/gcc/testsuite/g++.dg/template/error33.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/cp-tree.h trunk/gcc/cp/pt.c trunk/gcc/testsuite/g++.old-deja/g++.pt/crash11.C
Fixed by Jason's patch.
*** Bug 20133 has been marked as a duplicate of this bug. ***
*** Bug 34447 has been marked as a duplicate of this bug. ***
*** Bug 34822 has been marked as a duplicate of this bug. ***
*** Bug 35181 has been marked as a duplicate of this bug. ***
*** Bug 37970 has been marked as a duplicate of this bug. ***