[forwarded from http://bugs.debian.org/349087] g++ (GCC) 4.0.3 20060212 (prerelease) (Debian 4.0.2-9) falk@gluck:~% cat main.cpp template <typename T> class C { template <int NO> int fun() { return NO;} template <int NO> int fun2() { return 0 << fun<NO>::; //bad code of course here :) } }; falk@gluck:~% g++ -c main.cpp main.cpp: In member function 'int C<T>::fun2()': main.cpp:4: 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. Does not occur on alpha-linux-gnu, or with 3.3.6.
Hmm, works with 4.1.0 20060208 on x86_64.
And "4.0.3 20051105" on x86_64.
But not with "4.2.0 20060304" on x86_64: t.cc: In member function ‘int C<T>::fun2()’: t.cc:4: internal compiler error: tree check: expected class ‘type’, have ‘exceptional’ (error_mark) in cp_parser_class_name, at cp/parser.c:12746 Please submit a full bug report, with preprocessed source if appropriate. See <URL:http://gcc.gnu.org/bugs.html> for instructions. Must had been a change between there and today that caused it.
Actually it fails with checking since 3.4.0 so confirmed.
Testing a patch.
Subject: Bug number PR c++/26558 A patch for this bug has been added to the patch tracker. The mailing list url for the patch is http://gcc.gnu.org/ml/gcc-patches/2006-04/msg00725.html
Subject: Bug 26558 Author: reichelt Date: Wed Apr 19 22:03:24 2006 New Revision: 113096 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=113096 Log: PR c++/26558 * parser.c (cp_parser_class_name): Check for invalid typenames. Rearrange code. * g++.dg/parse/template19.C: New test. Added: trunk/gcc/testsuite/g++.dg/parse/template19.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/parser.c trunk/gcc/testsuite/ChangeLog
Subject: Bug 26558 Author: reichelt Date: Wed Apr 19 22:07:25 2006 New Revision: 113097 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=113097 Log: PR c++/26558 * parser.c (cp_parser_class_name): Check for invalid typenames. Rearrange code. * g++.dg/parse/template19.C: New test. Added: branches/gcc-4_1-branch/gcc/testsuite/g++.dg/parse/template19.C Modified: branches/gcc-4_1-branch/gcc/cp/ChangeLog branches/gcc-4_1-branch/gcc/cp/parser.c branches/gcc-4_1-branch/gcc/testsuite/ChangeLog
Subject: Bug 26558 Author: reichelt Date: Wed Apr 19 22:10:10 2006 New Revision: 113098 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=113098 Log: PR c++/26558 * parser.c (cp_parser_class_name): Check for invalid typenames. Rearrange code. * g++.dg/parse/template19.C: New test. Added: branches/gcc-4_0-branch/gcc/testsuite/g++.dg/parse/template19.C Modified: branches/gcc-4_0-branch/gcc/cp/ChangeLog branches/gcc-4_0-branch/gcc/cp/parser.c branches/gcc-4_0-branch/gcc/testsuite/ChangeLog
Fixed on mainline, 4.1 branch, and 4.0 branch.