Bug 29732 - [4.0 regression] ICE on invalid friend declaration
Summary: [4.0 regression] ICE on invalid friend declaration
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.3.0
: P2 normal
Target Milestone: 4.1.2
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-invalid-code, monitored
Depends on:
Blocks:
 
Reported: 2006-11-05 23:13 UTC by Volker Reichelt
Modified: 2007-02-03 20:55 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work: 4.1.2 4.2.0 4.3.0
Known to fail: 4.1.1
Last reconfirmed: 2006-11-26 00:22:09


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Volker Reichelt 2006-11-05 23:13:34 UTC
The following invalid code snippet triggers an ICE since GCC 4.0.0:

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

bug.cc: In member function 'void A::bar()':
bug.cc:4: internal compiler error: in retrieve_specialization, at cp/pt.c:847
Please submit a full bug report, [etc.]
Comment 1 Andrew Pinski 2006-11-26 00:22:09 UTC
Confirmed.
Comment 2 Mark Mitchell 2006-12-08 06:27:44 UTC
Subject: Bug 29732

Author: mmitchel
Date: Fri Dec  8 06:27:22 2006
New Revision: 119649

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=119649
Log:
	PR c++/29732
	* cp-tree.h (DECL_USE_TEMPLATE): Mention partial specializations.
	(explicit_class_specialization_p): Declare.
	* pt.c (explicit_class_specialization_p): New function.
	* parser.c (cp_parser_init_declarator): Check correct number of
	template parameters for in-class function definitions.
	(cp_parser_check_declrator_template_parameters): Stop looking for
	template classes when we find an explicit specialization.
	PR c++/29732
	* g++.dg/template/crash65.C: New test.
	* g++.dg/template/spec16.C: Tweak error markers.

Added:
    trunk/gcc/testsuite/g++.dg/template/crash65.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/cp-tree.h
    trunk/gcc/cp/parser.c
    trunk/gcc/cp/pt.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/g++.dg/template/spec16.C

Comment 3 Mark Mitchell 2006-12-08 08:10:38 UTC
Fixed in 4.3.0.
Comment 4 Mark Mitchell 2006-12-10 23:48:26 UTC
Subject: Bug 29732

Author: mmitchel
Date: Sun Dec 10 23:48:13 2006
New Revision: 119719

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=119719
Log:
	PR c++/29732
	* cp-tree.h (DECL_USE_TEMPLATE): Mention partial specializations.
	(explicit_class_specialization_p): Declare.
	* pt.c (explicit_class_specialization_p): New function.
	* parser.c (cp_parser_init_declarator): Check correct number of
	template parameters for in-class function definitions.
	(cp_parser_check_declarator_template_parameters): Stop looking for
	template classes when we find an explicit specialization.

	PR c++/29732
	* g++.dg/template/crash65.C: New test.
	* g++.dg/template/spec16.C: Tweak error markers.

	PR c++/29732
	* testsuite/ext/pb_assoc/example/mapping_level_neg.cc: Tweak error
	markers. 

Added:
    branches/gcc-4_1-branch/gcc/testsuite/g++.dg/template/crash65.C
Modified:
    branches/gcc-4_1-branch/gcc/cp/ChangeLog
    branches/gcc-4_1-branch/gcc/cp/cp-tree.h
    branches/gcc-4_1-branch/gcc/cp/parser.c
    branches/gcc-4_1-branch/gcc/cp/pt.c
    branches/gcc-4_1-branch/gcc/testsuite/g++.dg/template/spec16.C
    branches/gcc-4_1-branch/libstdc++-v3/ChangeLog
    branches/gcc-4_1-branch/libstdc++-v3/testsuite/ext/pb_assoc/example/mapping_level_neg.cc

Comment 5 Mark Mitchell 2006-12-12 01:47:15 UTC
Subject: Bug 29732

Author: mmitchel
Date: Tue Dec 12 01:46:57 2006
New Revision: 119759

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=119759
Log:
	PR c++/29732
	* cp-tree.h (DECL_USE_TEMPLATE): Mention partial specializations.
	(explicit_class_specialization_p): Declare.
	* pt.c (explicit_class_specialization_p): New function.
	* parser.c (cp_parser_init_declarator): Check correct number of
	template parameters for in-class function definitions.
	(cp_parser_check_declarator_template_parameters): Stop looking for
	template classes when we find an explicit specialization.
	PR c++/29732
	* g++.dg/template/crash65.C: New test.
	* g++.dg/template/spec16.C: Tweak error markers.

Added:
    branches/gcc-4_2-branch/gcc/testsuite/g++.dg/template/crash65.C
Modified:
    branches/gcc-4_2-branch/gcc/cp/ChangeLog
    branches/gcc-4_2-branch/gcc/cp/cp-tree.h
    branches/gcc-4_2-branch/gcc/cp/parser.c
    branches/gcc-4_2-branch/gcc/cp/pt.c
    branches/gcc-4_2-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_2-branch/gcc/testsuite/g++.dg/template/spec16.C

Comment 6 Mark Mitchell 2006-12-12 01:53:07 UTC
Fixed in 4.1.2, 4.2.0.
Comment 7 Gabriel Dos Reis 2007-02-03 20:55:17 UTC
Fixed in GCC-4.1.2.