This internal compiler error is being generated when I add the keyword 'typename' to a line of code that before that was giving me an error that: SAX/wrappers/saxlibxml2.h:310: error: expected primary-expression before '*' token. In the saxlibxml2.ii file, it is at line 35577. Specs from /usr/local/lib/gc/mips-sgi-irix6.5/3.4.4/specs Configured with ./configure Thread model: single gcc v3.4.4 Command line: g++ -c -I../../Include/SAX ../../Include/SAX/wrappers/saxlibxml2.cpp - o ../../Include/SAX/wrappers/saxlibxml2.o Compiler output: In file included from ../../Include/SAX/wrappers/saxlibxml2.cpp:7: ../../Include/SAX/wrappers/sax libxml2.h: In member function 'virtual std::auto_ptr<typename SAX::basic_XMLreader<string_type>::PropertyBase> SAX::libxml2_wrapper<string_type, string_adapter_type>::doGetProperty(const string_type&)': .../SAX/wrappers/saxlibxml2.:311: 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. gmake: *** [../../Include/SAX/wrappers/saxlibxml2.o] Error 1
Created attachment 9143 [details] The ii file from the compiler output where I received the seg fault. Line 35577 in this file contains the 'typename' that I added to make this compiler have an internal error. Without this keyword, I get a compile error. So, it seems to be required...but I can't build my source.
Confirmed, here is a reduced testcase: template<class a> struct cla { template<typename b> struct clb {}; }; namespace nasa { template<class a> struct clc {}; } template<class a> void doGetProperty(void) { cla<a>::clb<typename nasa::clc<a> *> *prop; } --- ICE --- pr22172.cc:12: internal compiler error: tree check: expected class 'type', have 'declaration' (namespace_decl) in dependent_type_p, at cp/pt.c:12027 Please submit a full bug report, with preprocessed source if appropriate. See <URL:http://gcc.gnu.org/bugs.html> for instructions.
Your line should read: typename SAX::basic_XMLReader<stringT>::template Property<SAX::basic_DeclHandler<stringT> *>* prop; If one fixes all four occurances in your file, the code compiles fine. With your version SAX::basic_XMLReader<stringT>::Property<typename SAX::basic_DeclHandler<stringT> *>* prop; "SAX::basic_XMLReader<stringT>::Property" is not a type, and therefore "<" is the operator "less_than" which is followed by a type (followed by some more stuff, but the compiler already crashed). An even shorter testcase is the following: =========================================== namespace N { template<int> struct A {}; } template<typename> void foo() { +typename N::A<0>; } ===========================================
Moving to 4.0.2 pre Mark.
Created attachment 9800 [details] We should give the user an error message Anyone have a better error message?
Only the following: if (TREE_CODE_CLASS (TREE_CODE (scope)) != tcc_type) Should be: if (!TYPE_P (scope)) -- Pinski
I don't think that this is a proper fix, since the following IMHO valid code snippet is rejected: ==================================================================== namespace N { template<int> struct A { operator int() const; }; } template<typename> void foo() { +typename N::A<0>(); } ====================================================================
So this is an ice-on-valid and an ice-on-invalid bug then?
The testcase in comment #3 shows an ice-on-invalid. The testcase in comment #7 is valid, and ices anyway. W.
Created attachment 9825 [details] Treat non-types as non-dependent This fixes the ice on all three testcases here. The first two now give errors and the third testcase compiles without error.
This path is OK, without the spurious addition of the blank line.
Subject: Bug 22172 CVSROOT: /cvs/gcc Module name: gcc Changes by: phython@gcc.gnu.org 2005-10-08 18:11:02 Modified files: gcc/cp : ChangeLog parser.c gcc/testsuite : ChangeLog Added files: gcc/testsuite/g++.dg/parse: crash30.C Log message: 2005-10-08 James A. Morrison <phython@gcc.gnu.org> PR c++/22172 * parser.c (cp_parser_postfix_expression) <RID_TYPENAME>: Treat nontype scopes as nondependent. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.4914&r2=1.4915 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/parser.c.diff?cvsroot=gcc&r1=1.360&r2=1.361 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.6151&r2=1.6152 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/parse/crash30.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
fixed in the previous patch.
Now also fixed on the 3.4 branch due to Mark's patch for PR 19253: http://gcc.gnu.org/ml/gcc-patches/2005-11/msg00141.html I'd really like to get that one backported to the 3.4 branch
I meant the 4.0 branch of course.
Backport for the 3.4 branch.
Subject: Bug 22172 Author: reichelt Date: Tue Nov 15 19:14:21 2005 New Revision: 107037 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=107037 Log: PR c++/19253 PR c++/22172 Backport from mainline: 2005-11-02 Mark Mitchell <mark@codesourcery.com> * parser.c (cp_parser_postfix_expression): Use cp_parser_elaborated_type_specifier to handle typename-types in functional casts. (cp_parser_enclosed_argument_list): Skip ahead to the end of the template argument list if the closing ">" is not found. Backport from mainline: 2005-11-02 Mark Mitchell <mark@codesourcery.com> PR c++/19253 * g++.dg/parse/typename10.C: New test. Backport from mainline: 2005-10-08 James A. Morrison <phython@gcc.gnu.org> PR c++/22172 * g++.dg/parse/crash30.C: New test. Added: branches/gcc-3_4-branch/gcc/testsuite/g++.dg/parse/crash30.C branches/gcc-3_4-branch/gcc/testsuite/g++.dg/parse/typename10.C Modified: branches/gcc-3_4-branch/gcc/cp/ChangeLog branches/gcc-3_4-branch/gcc/cp/parser.c branches/gcc-3_4-branch/gcc/testsuite/ChangeLog
Now also fixed on the 3.4 branch.