Bug 28641 - [4.2 regression] ICE calling template function with invalid template parameter
Summary: [4.2 regression] ICE calling template function with invalid template parameter
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.2.0
: P4 normal
Target Milestone: 4.2.0
Assignee: Not yet assigned to anyone
URL:
Keywords: error-recovery, ice-on-invalid-code, monitored
Depends on: 24791
Blocks: 27668
  Show dependency treegraph
 
Reported: 2006-08-07 17:43 UTC by Volker Reichelt
Modified: 2006-08-30 04:41 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2006-08-15 18:35:40


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Volker Reichelt 2006-08-07 17:43:45 UTC
The following invalid code snippet triggers an ICE on mainline and 4.1 branch:

===================================================
template<void> 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:2: internal compiler error: tree check: expected tree_list, have error_mark in type_unification_real, at cp/pt.c:9791
Please submit a full bug report, [etc.]

This is fallout from PR 27668.
Comment 1 Lee Millward 2006-08-09 18:43:20 UTC
Subject: Bug 28641

Author: lmillward
Date: Wed Aug  9 18:43:06 2006
New Revision: 116043

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=116043
Log:
2006-08-09  Lee Millward  <lee.millward@codesourcery.com>

       PR c++/28637
       * pt.c (coerce_template_parms): Copy across the
       invalid template arguments to the new template inner arguments.
       (retrieve_specialization): Robustify.

       * g++.dg/template/void3.C: New test.

       PR c++/28638
       * pt.c (coerce_template_template_parms): Robustify.
       
       * g++.dg/template/void4.C: New test.

       PR c++/28639
       * error.c (dump_template_parms): Robustify.

       PR c++/28640
       * pt.c (redeclare_class_template): Robustify

       * g++.dg/template/void5.C: New test.

       PR c++/28641
       * pt.c (type_unification_real): Robustify.


Added:
    trunk/gcc/testsuite/g++.dg/template/void3.C
    trunk/gcc/testsuite/g++.dg/template/void4.C
    trunk/gcc/testsuite/g++.dg/template/void5.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/error.c
    trunk/gcc/cp/pt.c
    trunk/gcc/testsuite/ChangeLog

Comment 2 Lee Millward 2006-08-09 18:47:24 UTC
Partially fixed on mainline, the testcase now ICE's in the same place as PR
24791. 
Comment 3 Lee Millward 2006-08-10 19:19:05 UTC
Subject: Bug 28641

Author: lmillward
Date: Thu Aug 10 19:18:37 2006
New Revision: 116068

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=116068
Log:
	PR c++/28594
	PR c++/28637
	PR c++/28638
	PR c++/28639
	PR c++/28640
	PR c++/28641

	Revert:
	2006-07-28  Lee Millward  <lee.millward@codesourcery.com>

        PR c++/27668
        PR c++/27962
        * pt.c (process_template_parm) Store invalid template
        parameters as error_mark_node in the paramater list.
        (push_inline_template_parms_recursive): Handle invalid
        template parameters.
        (comp_template_parms): Likewise.
        (check_default_tmpl_args): Likewise.
        (coerce_template_template_parms): Likewise.
        (coerce_template_parms): Likewise.
        (mangle_class_name_for_template): Likewise.
        (tsubst_template_parms): Likewise.
        * error.c (dump_template_argument_list): Likewise.

	* g++.dg/template/crash54.C: New test.
        * g++.dg/template/nontype16.C: New test.
        * g++.dg/template/nontype5.C: Adjust error markers


Removed:
    branches/gcc-4_1-branch/gcc/testsuite/g++.dg/template/crash54.C
    branches/gcc-4_1-branch/gcc/testsuite/g++.dg/template/nontype16.C
Modified:
    branches/gcc-4_1-branch/gcc/cp/ChangeLog
    branches/gcc-4_1-branch/gcc/cp/error.c
    branches/gcc-4_1-branch/gcc/cp/pt.c
    branches/gcc-4_1-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_1-branch/gcc/testsuite/g++.dg/template/nontype5.C

Comment 4 Lee Millward 2006-08-10 19:25:01 UTC
Fixed on the 4.1 branch by the reversal of the patch for PR 27668 so removing the 4.1 regression marker.
Comment 5 Volker Reichelt 2006-08-15 18:35:40 UTC
Confirmed as reproduced by Lee.
Comment 6 Lee Millward 2006-08-29 19:07:11 UTC
This doesn't ICE for me with current mainline:

bug.cc:1: error: 'void' is not a valid type for a template constant parameter
 void bar()
bug.cc:2: error: no matching function for call to 'foo()'

Can anyone else confirm this?
Comment 7 Andrew Pinski 2006-08-30 03:39:50 UTC
Been fixed since at least "4.2.0 20060826".
Comment 8 Andrew Pinski 2006-08-30 04:41:02 UTC
I had meant to close this as fixed the last time.