Bug 26938 - [4.1 regression] ICE with wrong number of template parameters
Summary: [4.1 regression] ICE with wrong number of template parameters
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
Depends on:
Blocks:
 
Reported: 2006-03-30 10:08 UTC by Volker Reichelt
Modified: 2008-07-04 15:25 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work: 4.2.0
Known to fail: 4.0.4 4.1.3
Last reconfirmed: 2006-09-23 16:34:47


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Volker Reichelt 2006-03-30 10:08:59 UTC
The following invalid testcase causes an ICE since GCC 3.1:

========================================
template<int, int = 0> struct A;

template<int> struct A
{
  A();
};

A<0> a;
========================================

bug.cc:1: error: previous declaration 'template<int <anonymous>, int <anonymous> > struct A'
bug.cc:3: error: used 2 template parameter(s) instead of 1
bug.cc: In constructor 'A<<anonymous>, <anonymous> >::A() [with int <anonymous> = 0]':
bug.cc:8:   instantiated from here
bug.cc:5: internal compiler error: tree check: accessed elt 2 of tree_vec with 1 elts in tsubst, at cp/pt.c:7080
Please submit a full bug report, [etc.]
Comment 1 Andrew Pinski 2006-03-30 23:18:48 UTC
Confirmed.
Comment 2 Andrew Pinski 2006-07-05 18:41:20 UTC
3.4.0 did not ICE with checking disabled.
Comment 3 Andrew Pinski 2006-07-16 08:31:12 UTC
Another testcase which I ran into while reducing the bootstrap failure:
template<typename _CharT, typename _Traits =int> class basic_istream;
template<typename _CharT>
struct basic_istream
{
    ~basic_istream(){}
};
class istrstream : public basic_istream<char>
{
    ~istrstream() { }
}
Comment 4 patchapp@dberlin.org 2006-09-23 16:35:19 UTC
Subject: Bug number PR c++/26938

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-09/msg01019.html
Comment 5 Lee Millward 2006-09-25 19:45:45 UTC
Subject: Bug 26938

Author: lmillward
Date: Mon Sep 25 19:45:34 2006
New Revision: 117205

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=117205
Log:
        PR c++/27329
        PR c++/26938
        * cp-tree.h (redeclare_class_template): Adjust declaration
        to return bool instead of void.
        * pt.c (redeclare_class_template): Update definition. Return
        false on error.
        * decl.c (xref_tag): Return error_mark_node if redeclare_class_template
        returned false.

        * g++.dg/template/crash58.C: New test.
        * g++.dg/template/crash59.C: New test.
        * g++.dg/parse/crash28.C: Adjust error markers.
        * g++.dg/template/crash34.C: Likewise.
        * g++.dg/template/friend31.C: Likewise.
        * g++.dg/template/crash32.C: Likewise.


Added:
    trunk/gcc/testsuite/g++.dg/template/crash58.C
    trunk/gcc/testsuite/g++.dg/template/crash59.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/cp-tree.h
    trunk/gcc/cp/decl.c
    trunk/gcc/cp/pt.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/g++.dg/parse/crash28.C
    trunk/gcc/testsuite/g++.dg/template/crash32.C
    trunk/gcc/testsuite/g++.dg/template/crash34.C
    trunk/gcc/testsuite/g++.dg/template/friend31.C

Comment 6 Lee Millward 2006-09-25 19:47:23 UTC
Fixed in 4.2.
Comment 7 Gabriel Dos Reis 2007-02-03 16:26:55 UTC
Won't fix in GCC-4.0.x.  Adjusting milestone.
Comment 8 Joseph S. Myers 2008-07-04 15:25:35 UTC
Closing 4.1 branch.