Bug 6949 - [3.3/3.4 regression] ICE in tsubst_decl, at cp/pt.c:5733
Summary: [3.3/3.4 regression] ICE in tsubst_decl, at cp/pt.c:5733
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.4.0
: P3 normal
Target Milestone: 3.3.1
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2002-06-06 13:36 UTC by rubin
Modified: 2004-01-17 04:22 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2003-06-22 21:16:55


Attachments
x.cc (150 bytes, application/octet-stream)
2003-05-21 15:16 UTC, rubin
Details

Note You need to log in before you can comment on or make changes to this bug.
Description rubin 2002-06-06 13:36:01 UTC
This ICE is caused by a class nested inside a local class of a templated member function.  The code snippet below is illustrative of the ICE in my application.  I found that small changes in the snippet cause the ICE to disappear, or to pop up in another place.  For example, just replacing

                      void funct();
with
                      void funct(){}

causes the ICE to disappear!

//========= Compiler output ================

$ gcc -v -save-temps GccBug2.cpp
Reading specs from /usr/local/lib/gcc-lib/i686-pc-cygwin/3.1/specs
Configured with: ../gcc-3.1/configure --enable-threads=win32
Thread model: win32
gcc version 3.1
// ... junk elided here ...
GNU CPP version 3.1 (cpplib) (80386, BSD syntax)
GNU C++ version 3.1 (i686-pc-cygwin)
        compiled by GNU C version 3.1.
GccBug2.cpp: In instantiation of `Struct::templatedMemberFunction(const T&) 
             [with T = int]::LocalClass::NestedClass':
GccBug2.cpp:6:   instantiated from `Struct::templatedMemberFunction(const T&) 
                 [with T = int]::LocalClass'
GccBug2.cpp:16:   instantiated from `void Struct::templatedMemberFunction
                  (const T&) [with T = int]'
GccBug2.cpp:23:   instantiated from here
GccBug2.cpp:7: Internal compiler error in tsubst_decl, at cp/pt.c:5733
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://www.gnu.org/software/gcc/bugs.html> for instructions.

//========= Source File GccBug2.cpp Begins Here ===========
struct Struct {
  template<class T> void templatedMemberFunction(const T&) {

    class LocalClass {

        struct NestedClass {
          void funct();
          };

        NestedClass nestedClassInstance_;

      public:
        void memberFunction() {nestedClassInstance_.funct();}
      };

    LocalClass localClass;
    localClass.memberFunction();
    };
};

void globalFunction() {
  Struct classInstance;
  classInstance.templatedMemberFunction(42);
}
//========= Source File GccBug2.cpp Ends Here =============

Release:
3.3/3.4

Environment:
Cygwin on Windows XP Professional

How-To-Repeat:
Invoke the compiler on GccBug2.cpp.
Comment 1 Kriang Lerdsuwanakij 2002-06-07 07:03:48 UTC
State-Changed-From-To: open->analyzed
State-Changed-Why: Confirmed.
Comment 2 Christian Ehrhardt 2003-05-12 18:58:18 UTC
From: "Christian Ehrhardt" <ehrhardt@mathematik.uni-ulm.de>
To: gcc-prs@gcc.gnu.org, rubin@contractor.net, gcc-bugs@gcc.gnu.org,
  gcc-gnats@gcc.gnu.org, nobody@gcc.gnu.org
Cc:  
Subject: Re: c++/6949: [2003-01-22] ICE in tsubst_decl, at cp/pt.c:5733
Date: Mon, 12 May 2003 18:58:18 +0200

 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=6949
 
 A further cleaned up testcase is below. The problem is that tsubst_decl
 expects non NULL DECL_TEMPLATE_INFO on the prototype declaration of the
 member function g in this assertion around line 6000 in cp/pt.c:
 
 |  /* Nobody should be tsubst'ing into non-template functions.  */
 |  my_friendly_assert (DECL_TEMPLATE_INFO (t) != NULL_TREE, 0);
 
 template<class T>
 void f(const T&)
 {
         struct B {
 		
                 void g (T);
         };
         B b;
 };
 void g()
 {
         f(42);
 }
 
    regards  Christian
Comment 3 Andrew Pinski 2003-06-14 22:07:46 UTC
This is a regression from 2.91.66, old but still a regression though.
Comment 5 CVS Commits 2003-07-02 04:11:36 UTC
Subject: Bug 6949

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	mmitchel@gcc.gnu.org	2003-07-02 04:11:30

Modified files:
	gcc/cp         : ChangeLog decl2.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/g++.dg/template: local3.C 

Log message:
	PR c++/6949
	* decl2.c (grokfield): Create TEMPLATE_DECLs for methods in local
	classes.
	
	PR c++/6949
	* g++.dg/template/local3.C: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.3480&r2=1.3481
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl2.c.diff?cvsroot=gcc&r1=1.634&r2=1.635
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.2825&r2=1.2826
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/local3.C.diff?cvsroot=gcc&r1=1.1&r2=1.2

Comment 6 Mark Mitchell 2003-07-02 04:49:15 UTC
Fixed in GCC 3.3.1, and GCC 3.4.