Bug 9781 - ICE in cp_parser_template_id
Summary: ICE in cp_parser_template_id
Status: RESOLVED DUPLICATE of bug 10583
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.4.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: error-recovery, ice-on-invalid-code, monitored
Depends on:
Blocks:
 
Reported: 2003-02-20 20:26 UTC by Wolfgang Bangerth
Modified: 2003-10-19 13:54 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2003-08-03 15:40:29


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Wolfgang Bangerth 2003-02-20 20:26:00 UTC
Found while tracking 9779:

This illegal piece of code generates an ICE in all
versions of gcc since at least 2.95:
----------------------------
template<bool> void foo(BOGUS) {
  sizeof (BOGUS);
}
template void foo<true>(BOGUS);
-----------------------------
g/x> /home/bangerth/bin/gcc-3.4-pre/bin/c++ -c z.cc
z.cc:1: error: variable or field `foo' declared void
z.cc:1: error: template declaration of `int foo'
z.cc:1: error: `BOGUS' has not been declared
z.cc:1: error: expected expected `;'
z.cc:4: internal compiler error: in cp_parser_template_id, at cp/parser.c:7996
Please submit a full bug report,

Since the code is obviously bogus, and the ICE is after
an error message, the priority is as low as could possibly
be. Nevertheless, if someone wants to fix this: a backtrace
is as this one:
#0  cp_parser_template_id (parser=0x40192080, template_keyword_p=false, 
    check_dependency_p=96) at ../../gcc-3.4-CVS/gcc/cp/parser.c:7996
#1  0x080f976e in cp_parser_class_name (parser=0x40192080, 
    typename_keyword_p=false, template_keyword_p=false, type_p=false, 
    check_access_p=true, check_dependency_p=true, class_head_p=false)
    at ../../gcc-3.4-CVS/gcc/cp/parser.c:11363
#2  0x080f1ceb in cp_parser_class_or_namespace_name (parser=0x40192080, 
    typename_keyword_p=false, template_keyword_p=false, 
    check_dependency_p=true, type_p=false)
    at ../../gcc-3.4-CVS/gcc/cp/parser.c:3489
#3  0x080f194f in cp_parser_nested_name_specifier_opt (parser=0x40192080, 
    typename_keyword_p=false, check_dependency_p=true, type_p=false)
    at ../../gcc-3.4-CVS/gcc/cp/parser.c:3301

At the spot where it aborts is this:
      /* If it's not a class-template or a template-template, it should be
	 a function-template.  */
      my_friendly_assert ((DECL_FUNCTION_TEMPLATE_P (template)
			   || TREE_CODE (template) == OVERLOAD
			   || BASELINK_P (template)),
			  20010716);
      

W.

Release:
unknown
Comment 1 Christian Ehrhardt 2003-02-23 16:38:53 UTC
State-Changed-From-To: open->analyzed
State-Changed-Why: Confirmed with 3.2 and 3.4. Already analyzed by Wolfgang.
Comment 2 Scott Brumbaugh 2003-08-28 22:26:27 UTC
This is similar to pr10310, proposed patch posted to gcc-patches:

http://gcc.gnu.org/ml/gcc-patches/2003-08/msg01888.html
Comment 3 Kriang Lerdsuwanakij 2003-10-19 13:54:07 UTC
Patch in progress.

*** This bug has been marked as a duplicate of 10583 ***
Comment 4 GCC Commits 2003-10-20 12:42:41 UTC
Subject: Bug 9781

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	lerdsuwa@gcc.gnu.org	2003-10-20 12:42:37

Modified files:
	gcc/cp         : ChangeLog decl.c pt.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/g++.dg/parse: crash13.C 

Log message:
	PR c++/9781, c++/10583, c++/11862
	* decl.c (cp_finish_decl): Exit immediately if decl is an
	error_mark_node.
	* pt.c (push_template_decl_real): Return error_mark_node for
	invalid template declaration of variable.
	
	* g++.dg/parse/crash13.C: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.3733&r2=1.3734
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl.c.diff?cvsroot=gcc&r1=1.1144&r2=1.1145
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/pt.c.diff?cvsroot=gcc&r1=1.788&r2=1.789
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.3133&r2=1.3134
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/parse/crash13.C.diff?cvsroot=gcc&r1=NONE&r2=1.1