Bug 19498 - ICE on invalid reference in template parameter
Summary: ICE on invalid reference in template parameter
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.0.0
: P2 minor
Target Milestone: 4.1.0
Assignee: Volker Reichelt
URL: http://gcc.gnu.org/ml/gcc-patches/200...
Keywords: error-recovery, ice-on-invalid-code, monitored, patch
Depends on:
Blocks:
 
Reported: 2005-01-18 08:56 UTC by Volker Reichelt
Modified: 2005-08-06 22:24 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2005-05-27 00:53:48


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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 CVS 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.