Bug 28737

Summary: [4.2 regression] ICE using invalid template class in specialization
Product: gcc Reporter: Volker Reichelt <reichelt>
Component: c++Assignee: Lee Millward <lmillward>
Status: RESOLVED FIXED    
Severity: minor CC: gcc-bugs
Priority: P4 Keywords: error-recovery, ice-on-invalid-code, monitored
Version: 4.2.0   
Target Milestone: 4.2.0   
Host: Target:
Build: Known to work:
Known to fail: Last reconfirmed: 2006-08-15 20:44:21
Bug Depends on:    
Bug Blocks: 27668    

Description Volker Reichelt 2006-08-15 18:41:38 UTC
The following invalid testcase triggers an ICE on mainline:

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

template<typename> struct B;

template<void N> struct B<A<N> > {};
=========================================

bug.cc:1: error: 'void' is not a valid type for a template constant parameter
bug.cc:5: error: 'void' is not a valid type for a template constant parameter
bug.cc:5: error: 'N' was not declared in this scope
bug.cc:5: error: template parameters not used in partial specialization:
bug.cc:5: internal compiler error: tree check: expected tree_list, have error_mark in process_partial_specialization, at cp/pt.c:2693
Please submit a full bug report, [etc.]

This is probably fallout from PR 27668.
Comment 1 Lee Millward 2006-08-15 20:44:21 UTC
Confirmed. I'll take a look at it.
Comment 2 Lee Millward 2006-08-26 17:41:32 UTC
Subject: Bug 28737

Author: lmillward
Date: Sat Aug 26 17:41:18 2006
New Revision: 116473

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=116473
Log:
        PR c++/28736
        PR c++/28737
        PR c++/28738
        * pt.c (process_template_parm): Store invalid template
        parameters as a TREE_LIST with a TREE_VALUE of error_mark_node.
        (push_inline_template_parms_recursive): Check for template
        parameters having a TREE_VALUE of error_mark_node rather than
        check the parameter itself.
        (mangle_class_name_for_template): Likewise.
        (comp_template_parms): When comparing the individual template
        parameters, return 1 if either is error_mark_node.
        (current_template_args): Robustify.
        (redeclare_class_template): Likewise.

        * g++.dg/template/void10.C: New test.
        * g++.dg/template/void8.C: New test.
        * g++.dg/template/void9.C: New test.

        * g++.dg/template/void3.C: Adjust error markers.
        * g++.dg/template/void4.C: Likewise.
        * g++.dg/template/crash55.C: Likewise.
        * g++.dg/template/void7.C: Likewise.


Added:
    trunk/gcc/testsuite/g++.dg/template/void10.C
    trunk/gcc/testsuite/g++.dg/template/void8.C
    trunk/gcc/testsuite/g++.dg/template/void9.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/void3.C
    trunk/gcc/testsuite/g++.dg/template/void4.C
    trunk/gcc/testsuite/g++.dg/template/void7.C

Comment 3 Lee Millward 2006-08-26 17:42:42 UTC
Fixed on mainline.