Bug 27668 - [4.1 regression] ICE with invalid template parameter
Summary: [4.1 regression] ICE with invalid template parameter
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.2.0
: P4 minor
Target Milestone: 4.2.0
Assignee: Not yet assigned to anyone
URL:
Keywords: error-recovery, ice-on-invalid-code, monitored
: 32320 (view as bug list)
Depends on: 27962 28594 28637 28638 28639 28640 28641 28736 28737 28738 28739 28742
Blocks:
  Show dependency treegraph
 
Reported: 2006-05-18 19:38 UTC by Volker Reichelt
Modified: 2008-07-04 15:32 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work: 4.2.0
Known to fail: 4.1.3
Last reconfirmed: 2006-07-26 18:04:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Volker Reichelt 2006-05-18 19:38:25 UTC
The following invalid code snippet triggers an ICE since GCC 3.4.0:

==================================================
template<typename class T, T = T()> struct A {};

template<int> void foo(A<int>);
==================================================

bug.cc:1: error: expected nested-name-specifier before 'class'
bug.cc:1: error: two or more data types in declaration of 'parameter'
bug.cc:1: error: 'struct T' is not a valid type for a template constant parameter
bug.cc:3: error: type/value mismatch at argument 1 in template parameter list for 'template<int <anonymous>, void <anonymous> > struct A'
bug.cc:3: error:   expected a constant of type 'int', got 'int'
bug.cc:3: internal compiler error: in value_dependent_expression_p, at cp/pt.c:12489
Please submit a full bug report, [etc.]
Comment 1 Wolfgang Bangerth 2006-05-26 15:06:09 UTC
Confirmed.
Comment 2 patchapp@dberlin.org 2006-07-20 17:40:20 UTC
Subject: Bug number PR c++/27668

A patch for this bug has been added to the patch tracker.
The mailing list url for the patch is http://gcc.gnu.org/ml/gcc-patches/2006-07/msg00868.html
Comment 3 patchapp@dberlin.org 2006-07-26 23:35:26 UTC
Subject: Bug number PR c++/27668

A patch for this bug has been added to the patch tracker.
The mailing list url for the patch is http://gcc.gnu.org/ml/gcc-patches/2006-07/msg01130.html
Comment 4 Lee Millward 2006-07-28 17:01:32 UTC
Subject: Bug 27668

Author: lmillward
Date: Fri Jul 28 17:01:19 2006
New Revision: 115800

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=115800
Log:
        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_arg): Likewise.
        (coerce_template_template_parms): Likewise.
        (mangle_class_name_for_template): Likewise.
        (tsubst_template_parms): Likewise.
        * error.c (dump_template_argument_list): Likewise.

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


Added:
    trunk/gcc/testsuite/g++.dg/template/crash55.C
    trunk/gcc/testsuite/g++.dg/template/nontype16.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/error.c
    trunk/gcc/cp/pt.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/g++.dg/template/nontype5.C
    trunk/gcc/testsuite/g++.dg/template/void2.C

Comment 5 Lee Millward 2006-07-28 17:02:28 UTC
Fixed on mainline. Will apply to 4.1 branch when testing completes.
Comment 6 Lee Millward 2006-07-28 21:17:37 UTC
Subject: Bug 27668

Author: lmillward
Date: Fri Jul 28 21:17:28 2006
New Revision: 115801

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=115801
Log:
        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.


Added:
    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 7 Lee Millward 2006-07-28 21:19:57 UTC
Fixed in 4.1.2
Comment 8 Lee Millward 2006-08-10 19:19:08 UTC
Subject: Bug 27668

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 9 Lee Millward 2006-08-10 19:21:19 UTC
The patch for this bug has been reverted on the 4.1 branch so re-adding the 4.1 regression marker.
Comment 10 Joe Buck 2007-01-07 06:07:13 UTC
I cannot duplicate this bug with gcc 4.1.1 or with the current 4.1 or 4.2 branches.  I don't get an ICE, just the expected error messages.

Is this bug still present?

Comment 11 Gabriel Dos Reis 2007-02-03 17:06:34 UTC
Won't fix in GCC-4.0.x.  Adjusting milestone conservatively.
It is not even sure it is still present on gcc-4_1- branch.
Comment 12 Volker Reichelt 2007-02-03 20:38:04 UTC
The ICE is still present on the 4.1 branch as of 2007-02-02.
It's been fixed on the 4.2 branch and mainline.
Comment 13 Andrew Pinski 2007-06-24 03:37:14 UTC
*** Bug 32320 has been marked as a duplicate of this bug. ***
Comment 14 Joseph S. Myers 2008-07-04 15:32:56 UTC
Closing 4.1 branch.