Bug 13797 - [3.3 regression] ICE on invalid template parameter
Summary: [3.3 regression] ICE on invalid template parameter
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.4.0
: P2 minor
Target Milestone: 3.3.3
Assignee: Kriang Lerdsuwanakij
URL:
Keywords: error-recovery, ice-on-invalid-code, monitored, patch
Depends on:
Blocks:
 
Reported: 2004-01-21 20:23 UTC by Ivan Godard
Modified: 2004-01-25 15:12 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2004-01-22 21:14:31


Attachments
Source code (-save-temps) (97.65 KB, text/plain)
2004-01-21 20:24 UTC, Ivan Godard
Details
Compiler output (-v -save-temps) (1.03 KB, text/plain)
2004-01-21 20:25 UTC, Ivan Godard
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ivan Godard 2004-01-21 20:23:20 UTC
 
Comment 1 Ivan Godard 2004-01-21 20:24:42 UTC
Created attachment 5547 [details]
Source code (-save-temps)
Comment 2 Ivan Godard 2004-01-21 20:25:16 UTC
Created attachment 5548 [details]
Compiler output (-v -save-temps)
Comment 3 Wolfgang Bangerth 2004-01-21 20:50:56 UTC
Confirmed. An ice-after-error. I don't have the time to reduce this 
at the moment, though, so I'll leave it to others. 
 
W. 
Comment 4 Volker Reichelt 2004-01-22 21:14:28 UTC
Here's a reduced testcase.

=======================================
template <int> struct A
{
    typedef A<0> B;
    template <B> struct B {};
};

A<0> a;
=======================================

With gcc 3.4.0 20031229 I get

PR13797.cc:4: error: `struct A<0>' is not a valid type for a template constant
parameter
PR13797.cc:4: error: declaration of `template<int <anonymous> > template<void
<anonymous> > struct A<<anonymous> >::B'
PR13797.cc:3: error: conflicts with previous declaration `typedef struct A<0>
A<<anonymous> >::B'
PR13797.cc: In instantiation of `A<0>':
PR13797.cc:7:   instantiated from here
PR13797.cc:3: error: `void' is not a valid type for a template constant
parameter
PR13797.cc:3: internal compiler error: in instantiate_class_template, at
cp/pt.c:5384
Please submit a full bug report,

If I replace line 4 with

    template <B> struct C {};

I get:

PR13797.cc:4: error: `struct A<0>' is not a valid type for a template constant
parameter
PR13797.cc: In instantiation of `A<0>':
PR13797.cc:7:   instantiated from here
PR13797.cc:4: error: `void' is not a valid type for a template constant
parameter
PR13797.cc:4: internal compiler error: tree check: expected record_type, have
error_mark in tsubst_decl, at cp/pt.c:5917
Please submit a full bug report,


GCC 2.95.3 issues a correct error message (thus we have a regression),
3.0 - 3.3.x go into an endless loop outputting the same error message
over and over again.
Comment 5 CVS Commits 2004-01-25 14:18:23 UTC
Subject: Bug 13797

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	lerdsuwa@gcc.gnu.org	2004-01-25 14:18:19

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

Log message:
	PR c++/13797
	* pt.c (instantiate_class_template): Add an error_mark_node
	check.
	(tsubst_decl) <TEMPLATE_DECL case>: Likewise.
	
	* g++.dg/template/nontype4.C: New test.
	* g++.dg/template/nontype5.C: Likewise.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.3905&r2=1.3906
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/pt.c.diff?cvsroot=gcc&r1=1.818&r2=1.819
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.3417&r2=1.3418
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/nontype4.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/nontype5.C.diff?cvsroot=gcc&r1=NONE&r2=1.1

Comment 7 Kriang Lerdsuwanakij 2004-01-25 14:37:19 UTC
Fixed in 3.4 and main line by

  http://gcc.gnu.org/ml/gcc-patches/2004-01/msg02731.html
Comment 8 Kriang Lerdsuwanakij 2004-01-25 14:40:05 UTC
For 3.3 branch, a patch is available

  http://gcc.gnu.org/ml/gcc-patches/2004-01/msg02732.html

however it only fixes the ICE exposed in the reduced testcases.

The original testSeries.ii is preprocessed with GCC 3.4 libstdc++
headers that GCC 3.3 refuses to compile and produces additional
ICE.  This ICE is probably treated as won't fix.
Comment 9 CVS Commits 2004-01-25 15:08:25 UTC
Subject: Bug 13797

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-3_3-branch
Changes by:	lerdsuwa@gcc.gnu.org	2004-01-25 15:08:20

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

Log message:
	PR c++/13797
	* pt.c (instantiate_class_template): Add an error_mark_node
	check.
	(tsubst_decl) <TEMPLATE_DECL case>: Likewise.
	
	Backport from mainline
	2003-05-09  Kriang Lerdsuwanakij  <lerdsuwa@users.sourceforge.net>
	
	PR c++/10555, c++/10576
	* pt.c (lookup_template_class): Handle class template with
	multiple levels of parameters when one of the levels contain
	errors.
	
	* g++.dg/template/nontype4.C: New test.
	* g++.dg/template/nontype5.C: Likewise.
	* g++.dg/template/memclass1.C: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.3076.2.242&r2=1.3076.2.243
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/pt.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.635.2.41&r2=1.635.2.42
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.2261.2.352&r2=1.2261.2.353
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/nontype4.C.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=NONE&r2=1.1.4.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/nontype5.C.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=NONE&r2=1.1.4.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/memclass1.C.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=NONE&r2=1.2.16.1

Comment 10 Kriang Lerdsuwanakij 2004-01-25 15:12:44 UTC
I'm closing this as fixed.