Bug 22153

Summary: [3.4/4.0/4.1 regression] ICE on invalid template specialization
Product: gcc Reporter: Volker Reichelt <reichelt>
Component: c++Assignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED FIXED    
Severity: minor CC: gcc-bugs, jconner
Priority: P2 Keywords: error-recovery, ice-on-invalid-code, monitored, patch
Version: 4.1.0   
Target Milestone: 3.4.5   
URL: http://gcc.gnu.org/ml/gcc-patches/2005-09/msg01274.html
Host: Target:
Build: Known to work: 3.3.3 3.4.5 4.0.3 4.1.0
Known to fail: 3.4.0 4.0.0 Last reconfirmed: 2005-09-04 18:20:29

Description Volker Reichelt 2005-06-22 21:45:57 UTC
Since GCC 3.4.0 we get an ICE on the following invalid code snippet:

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

template<int> struct A
{
    template<> friend void foo<0>();
};
=======================================

bug.cc:5: error: invalid explicit specialization before '>' token
bug.cc:5: error: explicit specialization in non-namespace scope 'struct
A<<anonymous> >'
bug.cc:5: error: enclosing class templates are not explicitly specialized
bug.cc:6: internal compiler error: Segmentation fault
Please submit a full bug report, [etc.]
Comment 1 Andrew Pinski 2005-06-22 22:10:28 UTC
Confirmed.
Comment 2 Joshua Conner 2005-10-11 17:31:57 UTC
Patch submitted here:

  http://gcc.gnu.org/ml/gcc-patches/2005-09/msg01274.html

Awaiting review...
Comment 3 jconner 2005-10-28 17:59:09 UTC
Subject: Bug 22153

Author: jconner
Date: Fri Oct 28 17:58:59 2005
New Revision: 105944

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=105944
Log:
PR c++/22153
* cp/parser.c (cp_parser_member_declaration): Detect and handle
a template specialization.
* testsuite/g++.dg/template/crash38.C: New test.
* testsuite/g++.dg/parse/explicit1.C: Change expected errors.


Added:
    trunk/gcc/testsuite/g++.dg/crash38.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/parser.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/g++.dg/parse/explicit1.C

Comment 4 Andrew Pinski 2005-10-28 18:09:46 UTC
Fixed.  Thanks Josh.
Comment 5 jconner 2005-10-28 18:47:34 UTC
Subject: Bug 22153

Author: jconner
Date: Fri Oct 28 18:47:28 2005
New Revision: 105946

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=105946
Log:
Merged from mainline change #105944:

PR c++/22153
* cp/parser.c (cp_parser_member_declaration): Detect and handle
a template specialization.
* testsuite/g++.dg/template/crash38.C: New test.
* testsuite/g++.dg/parse/explicit1.C: Change expected errors.


Added:
    branches/gcc-3_4-branch/gcc/testsuite/g++.dg/crash38.C
      - copied unchanged from r105944, trunk/gcc/testsuite/g++.dg/crash38.C
Modified:
    branches/gcc-3_4-branch/gcc/cp/ChangeLog
    branches/gcc-3_4-branch/gcc/cp/parser.c
    branches/gcc-3_4-branch/gcc/testsuite/ChangeLog
    branches/gcc-3_4-branch/gcc/testsuite/g++.dg/parse/explicit1.C

Comment 6 jconner 2005-10-28 18:57:38 UTC
Subject: Bug 22153

Author: jconner
Date: Fri Oct 28 18:57:33 2005
New Revision: 105947

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=105947
Log:
Merged from mainline change #105944:

PR c++/22153
* cp/parser.c (cp_parser_member_declaration): Detect and handle
a template specialization.
* testsuite/g++.dg/template/crash38.C: New test.
* testsuite/g++.dg/parse/explicit1.C: Change expected errors.


Added:
    branches/gcc-4_0-branch/gcc/testsuite/g++.dg/crash38.C
      - copied unchanged from r105944, trunk/gcc/testsuite/g++.dg/crash38.C
Modified:
    branches/gcc-4_0-branch/gcc/cp/ChangeLog
    branches/gcc-4_0-branch/gcc/cp/parser.c
    branches/gcc-4_0-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_0-branch/gcc/testsuite/g++.dg/parse/explicit1.C

Comment 7 Andrew Pinski 2005-10-28 18:58:46 UTC
Fixed in all open branches.