GCC Bugzilla has been upgraded from version 4.4.9 to 5.0rc3. If you see any problem, please report it to bug 64968.
Bug 22233 - [3.4 regression] ICE with wrong number of template parameters
Summary: [3.4 regression] ICE with wrong number of template parameters
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.1.0
: P2 minor
Target Milestone: 3.4.5
Assignee: Volker Reichelt
URL: http://gcc.gnu.org/ml/gcc-patches/200...
Keywords: error-recovery, ice-checking, ice-on-invalid-code, monitored, patch
Depends on:
Blocks:
 
Reported: 2005-06-29 14:09 UTC by Volker Reichelt
Modified: 2005-09-02 11:23 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work: 3.3.3
Known to fail: 3.4.0 4.0.0 4.1.0
Last reconfirmed: 2005-06-29 15:07:33


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Volker Reichelt 2005-06-29 14:09:16 UTC
The following invalid code snippet causes an ICE since GCC 3.3:

==============================================
template<int> struct A
{
  void foo();
};

template<int N, char> void A<N>::foo() {}

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

bug.cc:6: error: got 2 template parameters for `void A<<anonymous> >::foo()'
bug.cc:6: error:   but 1 required
bug.cc: In instantiation of `A<0>':
bug.cc:8:   instantiated from here
bug.cc:6: internal compiler error: tree check: accessed elt 2 of tree_vec with 
   1 elts in tsubst, at cp/pt.c:6707
Please submit a full bug report, [etc.]
Comment 1 Andrew Pinski 2005-06-29 15:07:33 UTC
Confirmed.
Comment 2 CVS Commits 2005-08-22 09:48:36 UTC
Subject: Bug 22233

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	reichelt@gcc.gnu.org	2005-08-22 09:48:26

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

Log message:
	PR c++/22233
	* pt.c (push_template_decl_real): Return error_mark_node if the
	number of template parameters does not match previous definition.
	
	* g++.dg/template/param1.C: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.4853&r2=1.4854
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/pt.c.diff?cvsroot=gcc&r1=1.1023&r2=1.1024
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.5946&r2=1.5947
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/param1.C.diff?cvsroot=gcc&r1=NONE&r2=1.1

Comment 3 CVS Commits 2005-08-22 09:55:08 UTC
Subject: Bug 22233

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-4_0-branch
Changes by:	reichelt@gcc.gnu.org	2005-08-22 09:54:43

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

Log message:
	PR c++/22233
	* pt.c (push_template_decl_real): Return error_mark_node if the
	number of template parameters does not match previous definition.
	
	* g++.dg/template/param1.C: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.4648.2.78&r2=1.4648.2.79
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/pt.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.978.2.16&r2=1.978.2.17
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.5084.2.343&r2=1.5084.2.344
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/param1.C.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=NONE&r2=1.1.2.1

Comment 4 Volker Reichelt 2005-08-22 11:17:07 UTC
Fixed on mainline and 4.0 branch.
Comment 5 Volker Reichelt 2005-08-24 05:37:21 UTC
Modified patch for the 3.4 branch posted.
Comment 6 CVS Commits 2005-09-02 11:20:54 UTC
Subject: Bug 22233

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-3_4-branch
Changes by:	reichelt@gcc.gnu.org	2005-09-02 11:20:22

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

Log message:
	PR c++/22233
	* pt.c (push_template_decl_real): Return error_mark_node if the
	number of template parameters does not match previous definition.
	* decl.c (start_function): Handle error_mark_node returned by
	push_template_decl.
	
	* g++.dg/template/param1.C: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.3892.2.237&r2=1.3892.2.238
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.1174.2.38&r2=1.1174.2.39
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/pt.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.816.2.58&r2=1.816.2.59
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.3389.2.429&r2=1.3389.2.430
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/param1.C.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.8.1

Comment 7 Volker Reichelt 2005-09-02 11:21:52 UTC
Fixed also on the 3.4 branch.
Comment 8 Volker Reichelt 2005-09-02 11:23:07 UTC
Btw, this was approved for the 3.4 branch by Gaby in private mail.