Bug 19498

Summary: ICE on invalid reference in template parameter
Product: gcc Reporter: Volker Reichelt <reichelt>
Component: c++Assignee: Volker Reichelt <reichelt>
Status: RESOLVED FIXED    
Severity: minor CC: gcc-bugs
Priority: P2 Keywords: error-recovery, ice-on-invalid-code, monitored, patch
Version: 4.0.0   
Target Milestone: 4.1.0   
URL: http://gcc.gnu.org/ml/gcc-patches/2005-08/msg00212.html
Host: Target:
Build: Known to work:
Known to fail: Last reconfirmed: 2005-05-27 00:53:48

Description Volker Reichelt 2005-01-18 08:56:33 UTC
The following invalid code snippet causes an ICE since at least gcc 2.95.3:

==============================
template<typename T> struct A
{
    template<T&> struct B;
};

A<void> a;
==============================

bug3.cc: In instantiation of 'A<void>':
bug3.cc:6:   instantiated from here
bug3.cc:3: error: forming reference to void
bug3.cc:3: internal compiler error: tree check: expected tree_vec, have
error_mark in retrieve_specialization, at cp/pt.c:822
Please submit a full bug report, [etc.]

Using "int&" instead of "void" to instantiate the template also causes
an ICE.
Comment 1 Andrew Pinski 2005-01-18 14:28:42 UTC
Confirmed.
Comment 2 Volker Reichelt 2005-08-03 16:07:35 UTC
Testing a patch.
Comment 3 GCC Commits 2005-08-06 22:22:57 UTC
Subject: Bug 19498

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	reichelt@gcc.gnu.org	2005-08-06 22:22:47

Modified files:
	gcc/cp         : ChangeLog pt.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/g++.dg/template: instantiate7.C 

Log message:
	PR c++/19498
	* pt.c (tsubst_decl) <case TEMPLATE_DECL>: Return ERROR_MARK_NODE
	if substitution of template args did not succeed.
	
	* g++.dg/template/instantiate7.C: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.4842&r2=1.4843
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/pt.c.diff?cvsroot=gcc&r1=1.1019&r2=1.1020
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.5887&r2=1.5888
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/instantiate7.C.diff?cvsroot=gcc&r1=NONE&r2=1.1

Comment 4 Volker Reichelt 2005-08-06 22:24:33 UTC
Fixed on mainline.