Bug 28638 - [4.1 regression] ICE on invalid template parameter
Summary: [4.1 regression] ICE on invalid template parameter
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.2.0
: P3 normal
Target Milestone: 4.1.2
Assignee: Lee Millward
URL:
Keywords: error-recovery, ice-on-invalid-code, monitored
Depends on:
Blocks: 27668
  Show dependency treegraph
 
Reported: 2006-08-07 17:30 UTC by Volker Reichelt
Modified: 2006-08-26 03:40 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2006-08-07 20:02:08


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:30:07 UTC
The following invalid code snippet triggers a ICE on mainline and 4.1 branch:

===================================================
template<void> struct A;

template<template<int> class> struct B {};

B<A> b;
===================================================

bug.cc:1: error: 'void' is not a valid type for a template constant parameter
bug.cc:5: internal compiler error: tree check: expected tree_list, have error_mark in coerce_template_template_parms, at cp/pt.c:3792
Please submit a full bug report, [etc.]

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

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:45:02 UTC
Fixed on mainline.
Comment 3 Lee Millward 2006-08-10 19:19:05 UTC
Subject: Bug 28638

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:23:26 UTC
Fixed on the 4.1 branch by the reversal of the patch for PR 27668.