Bug 6440 - [3.2/3.3/3.4 regression] template specializations cause ICE
Summary: [3.2/3.3/3.4 regression] template specializations cause ICE
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.0.4
: P3 normal
Target Milestone: ---
Assignee: Kriang Lerdsuwanakij
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2002-04-24 12:16 UTC by Jens Maurer
Modified: 2004-01-17 04:22 UTC (History)
5 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jens Maurer 2002-04-24 12:16:00 UTC
See ISO C++ core issue 336.

spec-example-c336.cc:14: Internal compiler error in lookup_template_class, at 
   cp/pt.c:3960
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://www.gnu.org/software/gcc/bugs.html> for instructions.

Release:
3.0.4 and recent CVS checkout

Environment:
Linux 2.4.17

How-To-Repeat:
    template<class T1> struct A { 
        template<class T2> struct B { 
            template<class T3> void mf1(T3);
            void mf2(); 
        }; 
    }; 

    template<> template<class X> 
        struct A<int>::B {
            template<class T> void mf1(T);
    }; 

    template<> template<> template<class T> 
        void A<int>::B<double>::mf1(T t) { } 
    template<class Y> template<> 
        void A<Y>::B<double>::mf2() { }
Comment 1 Kriang Lerdsuwanakij 2002-05-14 06:43:14 UTC
State-Changed-From-To: open->analyzed
State-Changed-Why: Confirmed, ICE on both 3.1 branch and main trunk.  Perhaps
    the right syntax could be:
      template<> template<class X> 
        class A<int>::B<X> {
                       ^^^
    
    Both 3.1 and trunk work fine with the above code.
Comment 2 Jens Maurer 2002-05-20 16:15:49 UTC
From: Jens Maurer <Jens.Maurer@gmx.net>
To: lerdsuwa@gcc.gnu.org, gcc-bugs@gcc.gnu.org, gcc-prs@gcc.gnu.org,
   nobody@gcc.gnu.org, gcc-gnats@gcc.gnu.org
Cc:  
Subject: Re: c++/6440: template specializations cause ICE
Date: Mon, 20 May 2002 16:15:49 +0200

 14.7.3p18 appears to say that A<int>::B<X> is not the right
 syntax, because A<int>::B is a genuine class template (for B),
 and A<int>::B has not been declared previously.
 
 Jens Maurer
 
 
 lerdsuwa@gcc.gnu.org wrote:
 > 
 > Synopsis: template specializations cause ICE
 > 
 > State-Changed-From-To: open->analyzed
 > State-Changed-By: lerdsuwa
 > State-Changed-When: Tue May 14 06:43:14 2002
 > State-Changed-Why:
 >     Confirmed, ICE on both 3.1 branch and main trunk.  Perhaps
 >     the right syntax could be:
 >       template<> template<class X>
 >         class A<int>::B<X> {
 >                        ^^^
 > 
 >     Both 3.1 and trunk work fine with the above code.
 > 
 > http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=6440
 
 
 

Comment 3 Giovanni Bajo 2003-01-23 05:14:16 UTC
From: "Giovanni Bajo" <giovannibajo@libero.it>
To: <gcc-gnats@gcc.gnu.org>,
	<Jens.Maurer@gmx.net>,
	<gcc-bugs@gcc.gnu.org>,
	<nobody@gcc.gnu.org>,
	<gcc-prs@gcc.gnu.org>
Cc:  
Subject: Re: c++/6440: [2003-01-22] template specializations cause ICE
Date: Thu, 23 Jan 2003 05:14:16 +0100

 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&p
 r=6440
 
 I agree that A<int>::B is the right syntax, and it is indeed accepted by
 EDG.
 
 Moreover, please notice that the last definition in the test is ill-formed:
 
     template<class Y> template<>
         void A<Y>::B<double>::mf2() { }
 
 since you cannot specialize B<> without specializing A<>. I think that line
 should be removed from the test (unless it's required to trigger the ICE),
 otherwise "ice-on-legal-code" should be change to "illegal-code".
 
Comment 4 Kriang Lerdsuwanakij 2003-02-04 14:24:53 UTC
Responsible-Changed-From-To: unassigned->lerdsuwa
Responsible-Changed-Why: Working on a fix.
Comment 5 Kriang Lerdsuwanakij 2003-03-05 20:58:46 UTC
From: Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
To: gcc-gnats@gcc.gnu.org, Jens.Maurer@gmx.net, gcc-bugs@gcc.gnu.org,
        lerdsuwa@gcc.gnu.org, gcc-prs@gcc.gnu.org
Cc:  
Subject: Re: c++/6440: [3.2/3.3/3.4 regression] template specializations cause
 ICE
Date: Wed, 05 Mar 2003 20:58:46 +0700

 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=6440
 
 The revised patch for this bug is just submitted:
 
 	http://gcc.gnu.org/ml/gcc-patches/2003-03/msg00423.html
 

Comment 6 Kriang Lerdsuwanakij 2003-03-15 10:08:32 UTC
From: lerdsuwa@gcc.gnu.org
To: gcc-gnats@gcc.gnu.org
Cc:  
Subject: c++/6440
Date: 15 Mar 2003 10:08:32 -0000

 CVSROOT:	/cvs/gcc
 Module name:	gcc
 Changes by:	lerdsuwa@gcc.gnu.org	2003-03-15 10:08:31
 
 Modified files:
 	gcc/cp         : pt.c ChangeLog 
 	gcc/testsuite  : ChangeLog 
 Added files:
 	gcc/testsuite/g++.dg/template: spec7.C spec8.C 
 
 Log message:
 	PR c++/6440
 	* pt.c (maybe_process_partial_specialization): Handle
 	member class template when enclosing class template is
 	explicit specialized.
 	(most_general_template): Stop looking when DECL is already
 	specialized.
 	
 	* g++.dg/template/spec7.C: New test.
 	* g++.dg/template/spec8.C: Likewise.
 
 Patches:
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/pt.c.diff?cvsroot=gcc&r1=1.669&r2=1.670
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.3272&r2=1.3273
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.2508&r2=1.2509
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/spec7.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/spec8.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
 
Comment 7 Kriang Lerdsuwanakij 2003-03-15 10:16:51 UTC
From: lerdsuwa@gcc.gnu.org
To: gcc-gnats@gcc.gnu.org
Cc:  
Subject: c++/6440
Date: 15 Mar 2003 10:16:51 -0000

 CVSROOT:	/cvs/gcc
 Module name:	gcc
 Branch: 	gcc-3_3-branch
 Changes by:	lerdsuwa@gcc.gnu.org	2003-03-15 10:16:51
 
 Modified files:
 	gcc/cp         : pt.c ChangeLog 
 	gcc/testsuite  : ChangeLog 
 Added files:
 	gcc/testsuite/g++.dg/template: spec7.C spec8.C 
 
 Log message:
 	PR c++/6440
 	* pt.c (maybe_process_partial_specialization): Handle
 	member class template when enclosing class template is
 	explicit specialized.
 	(most_general_template): Stop looking when DECL is already
 	specialized.
 	
 	* g++.dg/template/spec7.C: New test.
 	* g++.dg/template/spec8.C: Likewise.
 
 Patches:
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/pt.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.635.2.13&r2=1.635.2.14
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.3076.2.84&r2=1.3076.2.85
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.2261.2.99&r2=1.2261.2.100
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/spec7.C.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=NONE&r2=1.1.2.1
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/spec8.C.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=NONE&r2=1.1.2.1
 

Comment 8 Kriang Lerdsuwanakij 2003-03-15 10:22:25 UTC
State-Changed-From-To: analyzed->closed
State-Changed-Why: Fixed in 3.3/3.4.
Comment 9 Gabriel Dos Reis 2003-03-15 11:33:54 UTC
From: Gabriel Dos Reis <gdr@integrable-solutions.net>
To: lerdsuwa@gcc.gnu.org
Cc: Jens.Maurer@gmx.net, gcc-bugs@gcc.gnu.org, gcc-gnats@gcc.gnu.org,
   lerdsuwa@gcc.gnu.org
Subject: Re: c++/6440: [3.2/3.3/3.4 regression] template specializations cause ICE
Date: 15 Mar 2003 11:33:54 +0100

 lerdsuwa@gcc.gnu.org writes:
 
 | Synopsis: [3.2/3.3/3.4 regression] template specializations cause ICE
 | 
 | State-Changed-From-To: analyzed->closed
 | State-Changed-By: lerdsuwa
 | State-Changed-When: Sat Mar 15 10:22:25 2003
 | State-Changed-Why:
 |     Fixed in 3.3/3.4.
 
 Is the patch easily backportable to 3.2.x?
 
 -- Gaby

Comment 10 Kriang Lerdsuwanakij 2003-03-16 14:14:26 UTC
From: Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
To: Gabriel Dos Reis <gdr@integrable-solutions.net>
Cc: lerdsuwa@gcc.gnu.org, Jens.Maurer@gmx.net, gcc-bugs@gcc.gnu.org,
        gcc-gnats@gcc.gnu.org
Subject: Re: c++/6440: [3.2/3.3/3.4 regression] template specializations cause
 ICE
Date: Sun, 16 Mar 2003 14:14:26 +0700

 Gabriel Dos Reis wrote:
 
 >lerdsuwa@gcc.gnu.org writes:
 >
 >| Synopsis: [3.2/3.3/3.4 regression] template specializations cause ICE
 >| 
 >| State-Changed-From-To: analyzed->closed
 >| State-Changed-By: lerdsuwa
 >| State-Changed-When: Sat Mar 15 10:22:25 2003
 >| State-Changed-Why:
 >|     Fixed in 3.3/3.4.
 >
 >Is the patch easily backportable to 3.2.x?
 >
 Backparting this is straightforward.  The parser in 3.2 is pretty much 
 the same as 3.3 I see no problem there.
 
 --Kriang
 
 
 

Comment 11 Kriang Lerdsuwanakij 2003-03-16 14:28:43 UTC
From: lerdsuwa@gcc.gnu.org
To: gcc-gnats@gcc.gnu.org
Cc:  
Subject: c++/6440
Date: 16 Mar 2003 14:28:43 -0000

 CVSROOT:	/cvs/gcc
 Module name:	gcc
 Branch: 	gcc-3_2-branch
 Changes by:	lerdsuwa@gcc.gnu.org	2003-03-16 14:28:43
 
 Modified files:
 	gcc/cp         : pt.c ChangeLog 
 	gcc/testsuite  : ChangeLog 
 Added files:
 	gcc/testsuite/g++.dg/template: spec7.C spec8.C 
 
 Log message:
 	PR c++/6440
 	* pt.c (maybe_process_partial_specialization): Handle
 	member class template when enclosing class template is
 	explicit specialized.
 	(most_general_template): Stop looking when DECL is already
 	specialized.
 	
 	* g++.dg/template/spec7.C: New test.
 	* g++.dg/template/spec8.C: Likewise.
 
 Patches:
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/pt.c.diff?cvsroot=gcc&only_with_tag=gcc-3_2-branch&r1=1.578.2.11.2.9&r2=1.578.2.11.2.10
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_2-branch&r1=1.2685.2.114.2.70&r2=1.2685.2.114.2.71
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_2-branch&r1=1.1672.2.166.2.109&r2=1.1672.2.166.2.110
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/spec7.C.diff?cvsroot=gcc&only_with_tag=gcc-3_2-branch&r1=NONE&r2=1.1.4.1
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/spec8.C.diff?cvsroot=gcc&only_with_tag=gcc-3_2-branch&r1=NONE&r2=1.1.4.1