Bug 31446 - [4.2 regression] ICE with invalid template parameter
Summary: [4.2 regression] ICE with invalid template parameter
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.3.0
: P5 normal
Target Milestone: 4.3.0
Assignee: Not yet assigned to anyone
URL:
Keywords: error-recovery, ice-on-invalid-code, monitored
Depends on:
Blocks:
 
Reported: 2007-04-02 21:40 UTC by Volker Reichelt
Modified: 2009-03-30 21:43 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work: 4.3.0
Known to fail: 4.2.5
Last reconfirmed: 2007-09-20 09:34:45


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Volker Reichelt 2007-04-02 21:40:54 UTC
The following invalid code snippet triggers an ICE on mainline and 4.2 branch:

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

void bar()
{
  foo<0>();
}
===========================================================

bug.cc:1: error: 'void' is not a valid type for a template constant parameter
bug.cc: In function 'void bar()':
bug.cc:8: internal compiler error: in retrieve_specialization, at cp/pt.c:856
Please submit a full bug report, [etc.]
Comment 1 Mark Mitchell 2007-05-14 22:27:42 UTC
Will not be fixed in 4.2.0; retargeting at 4.2.1.
Comment 2 Paolo Carlini 2007-09-19 17:59:55 UTC
Hi again... A regression hunt would be useful for this one too...
Comment 3 Janis Johnson 2007-09-19 23:20:40 UTC
A regression hunt on powerpc-linux using the submitter's test case identified the following patch:

    http://gcc.gnu.org/viewcvs?view=rev&rev=115800

    r115800 | lmillward | 2006-07-28 17:01:19 +0000 (Fri, 28 Jul 2006)

(By the way, I think regression hunts are fun and don't mind doing them.  They usually take very little effort.)
Comment 4 Paolo Carlini 2007-09-20 09:34:44 UTC
Great Janis, I will ask your help more often: hunts are very helpful for quickly fixing recent bugs!
Comment 5 Paolo Carlini 2007-09-26 18:24:19 UTC
Seems due to a trivial thinko in the changes for 27668, 27962, etc..
Comment 6 Paolo Carlini 2007-09-28 15:40:47 UTC
Patch at:

  http://gcc.gnu.org/ml/gcc-patches/2007-09/msg01933.html
Comment 7 Paolo Carlini 2007-09-30 15:52:59 UTC
NB: the patch also fixes PR30299
Comment 8 Paolo Carlini 2007-10-01 00:52:34 UTC
NB: the patch also fixes PR28639
Comment 9 Mark Mitchell 2007-10-09 19:22:10 UTC
Change target milestone to 4.2.3, as 4.2.2 has been released.
Comment 10 paolo@gcc.gnu.org 2007-10-16 22:22:12 UTC
Subject: Bug 31446

Author: paolo
Date: Tue Oct 16 22:21:59 2007
New Revision: 129391

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=129391
Log:
/cp
2007-10-16  Paolo Carlini  <pcarlini@suse.de>

	PR c++/31446
	* pt.c (current_template_args): Do not change TREE_LIST elements
	with a TREE_VALUE of error_mark_node.

/testsuite
2007-10-16  Paolo Carlini  <pcarlini@suse.de>

	PR c++/31446
	* g++.dg/template/void11.C: New.
	* g++.dg/template/void2.C: Adjust error markers.
	* g++.dg/template/void10.C: Likewise.
	* g++.dg/template/crash55.C: Likewise.

Added:
    trunk/gcc/testsuite/g++.dg/template/void11.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/pt.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/g++.dg/template/crash55.C
    trunk/gcc/testsuite/g++.dg/template/void10.C
    trunk/gcc/testsuite/g++.dg/template/void2.C

Comment 11 Joseph S. Myers 2008-02-01 16:53:55 UTC
4.2.3 is being released now, changing milestones of open bugs to 4.2.4.
Comment 12 Joseph S. Myers 2008-05-19 20:23:03 UTC
4.2.4 is being released, changing milestones to 4.2.5.
Comment 13 Joseph S. Myers 2009-03-30 21:43:50 UTC
Closing 4.2 branch, fixed in 4.3.