User account creation filtered due to spam.

Bug 7053 - [3.3 Regression] ICE when declaring a function already defined as a friend method of a template class
Summary: [3.3 Regression] ICE when declaring a function already defined as a friend me...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.1.1
: P3 normal
Target Milestone: 3.3.1
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-valid-code, monitored
Depends on:
Blocks:
 
Reported: 2002-06-17 04:06 UTC by nicolas.tisserand
Modified: 2003-07-14 20:22 UTC (History)
4 users (show)

See Also:
Host: i386-pc-linux-gnu
Target: i386-pc-linux-gnu
Build: i386-pc-linux-gnu
Known to work:
Known to fail:
Last reconfirmed: 2003-06-23 12:49:30


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description nicolas.tisserand 2002-06-17 04:06:01 UTC
gcc does not tolerate a redeclaration of a friend method,
oustside of its original class, when the parameter is
template dependent.

g++-3.1 -v -save-temps ICE.cc                                                                                                                   12:55
Reading specs from /usr/lib/gcc-lib/i386-linux/3.1.1/specs
Configured with: /mnt/data/gcc-3.1/gcc-3.1-3.1.1ds1/src/configure -v --enable-languages=c,c++,java,f77,proto,objc,ada --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-gxx-include-dir=/usr/include/g++-v3-3.1 --enable-shared --with-system-zlib --enable-long-long --enable-nls --without-included-gettext --enable-clocale=gnu --enable-threads=posix --enable-java-gc=boehm --enable-objc-gc i386-linux
Thread model: posix
gcc version 3.1.1 20020606 (Debian prerelease)
 /usr/lib/gcc-lib/i386-linux/3.1.1/cpp0 -lang-c++ -D__GNUG__=3 -D__DEPRECATED -D__EXCEPTIONS -D__GXX_ABI_VERSION=100 -v -D__GNUC__=3 -D__GNUC_MINOR__=1 -D__GNUC_PATCHLEVEL__=1 -D__ELF__ -Dunix -D__gnu_linux__ -Dlinux -D__ELF__ -D__unix__ -D__gnu_linux__ -D__linux__ -D__unix -D__linux -Asystem=posix -D__NO_INLINE__ -D__STDC_HOSTED__=1 -D_GNU_SOURCE -Acpu=i386 -Amachine=i386 -Di386 -D__i386 -D__i386__ -D__tune_i386__ ICE.cc ICE.ii
GNU CPP version 3.1.1 20020606 (Debian prerelease) (cpplib) (i386 Linux/ELF)
ignoring nonexistent directory "/usr/i386-linux/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/include/g++-v3-3.1
 /usr/include/g++-v3-3.1/i386-linux
 /usr/include/g++-v3-3.1/backward
 /usr/local/include
 /usr/lib/gcc-lib/i386-linux/3.1.1/include
 /usr/include
End of search list.
 /usr/lib/gcc-lib/i386-linux/3.1.1/cc1plus -fpreprocessed ICE.ii -quiet -dumpbase ICE.cc -version -o ICE.s
GNU CPP version 3.1.1 20020606 (Debian prerelease) (cpplib) (i386 Linux/ELF)
GNU C++ version 3.1.1 20020606 (Debian prerelease) (i386-linux)
        compiled by GNU C version 3.1.1 20020606 (Debian prerelease).
ICE.cc: In instantiation of `void bar(A<int>)':
ICE.cc:13:   instantiated from here
ICE.cc:4: Internal compiler error in regenerate_decl_from_template, at cp/pt.c:
   9779
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.1.1 20020606 (Debian prerelease) (Debian testing/unstable)

Environment:
System: Linux ouarzazate 2.4.17 #1 Sun Mar 10 19:25:30 CET 2002 i686 unknown
Architecture: i686

	
host: i386-pc-linux-gnu
build: i386-pc-linux-gnu
target: i386-pc-linux-gnu
configured with: /mnt/data/gcc-3.1/gcc-3.1-3.1.1ds1/src/configure -v --enable-languages=c,c++,java,f77,proto,objc,ada --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-gxx-include-dir=/usr/include/g++-v3-3.1 --enable-shared --with-system-zlib --enable-long-long --enable-nls --without-included-gettext --enable-clocale=gnu --enable-threads=posix --enable-java-gc=boehm --enable-objc-gc i386-linux

How-To-Repeat:
template <class T>
struct A
{
  friend void bar(A<T> a) {}
};

void bar(A<int>);

int main()
{
  A<int> a;

  bar(a);
}
Comment 1 nicolas.tisserand 2002-06-17 04:06:01 UTC
Fix:
I do not know.
Comment 2 Kriang Lerdsuwanakij 2002-06-17 07:06:21 UTC
State-Changed-From-To: open->analyzed
State-Changed-Why: Confirmed.
Comment 3 Volker Reichelt 2003-05-06 18:27:42 UTC
From: Volker Reichelt <reichelt@igpm.rwth-aachen.de>
To: gcc-gnats@gcc.gnu.org, gcc-bugs@gcc.gnu.org, nicolas.tisserand@lrde.epita.fr
Cc:  
Subject: Re: c++/7053: [2003-01-22] ICE when declaring a function already
 defined as a friend method of a template class
Date: Tue, 06 May 2003 18:27:42 +0200 (CEST)

 The code crashes gcc since at least 2.95.x.
 This affects also 3.3 branch and mainline as of 2003-05-06.
 
 Regards,
 Volker
 
 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=7053
Comment 4 Andrew Pinski 2003-07-14 03:47:32 UTC
It did not ICE in 2.91.66 so this is a regresion but an old one thogugh.
Comment 5 Mark Mitchell 2003-07-14 05:44:57 UTC
Fixed in GCC 3.4 as of 2003-07-13.
Comment 6 CVS Commits 2003-07-14 20:18:27 UTC
Subject: Bug 7053

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-3_3-branch
Changes by:	mmitchel@gcc.gnu.org	2003-07-14 20:18:20

Modified files:
	gcc/cp         : ChangeLog pt.c 
	gcc/testsuite  : ChangeLog 

Log message:
	PR c++/7053
	* pt.c (unregister_specialization): Rename to ...
	(reregister_specialization): ... this.
	(tsubst_friend_function): Use it.
	(regenerate_decl_from_template): Likewise.
	
	PR c++/7053
	* g++.dg/template/friend20.C: New test.

Patches:
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.183&r2=1.3076.2.184
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.33&r2=1.635.2.34
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.232&r2=1.2261.2.233

Comment 7 CVS Commits 2003-07-14 20:20:31 UTC
Subject: Bug 7053

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	mmitchel@gcc.gnu.org	2003-07-14 20:20:28

Modified files:
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/g++.dg/template: friend20.C 

Log message:
	PR c++/7053
	* g++.dg/template/friend20.C: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.2874&r2=1.2875
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/friend20.C.diff?cvsroot=gcc&r1=NONE&r2=1.1

Comment 8 Mark Mitchell 2003-07-14 20:22:43 UTC
Fixed in GCC 3.3.1, GCC 3.4.
Comment 9 CVS Commits 2003-07-15 00:29:10 UTC
Subject: Bug 7053

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-3_3-branch
Changes by:	mmitchel@gcc.gnu.org	2003-07-15 00:29:08

Added files:
	gcc/testsuite/g++.dg/template: friend20.C 

Log message:
	PR c++/7053
	* g++.dg/template/friend20.C: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/friend20.C.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=NONE&r2=1.1.2.1

Comment 10 CVS Commits 2005-01-05 09:21:52 UTC
Subject: Bug 7053

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-3_2-rhl8-branch
Changes by:	jakub@gcc.gnu.org	2005-01-05 09:21:41

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

Log message:
	2003-07-14  Mark Mitchell  <mark@codesourcery.com>
	
	PR c++/7053
	* pt.c (unregister_specialization): Rename to ...
	(reregister_specialization): ... this.
	(tsubst_friend_function): Use it.
	(regenerate_decl_from_template): Likewise.
	
	* g++.dg/template/friend20.C: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_2-rhl8-branch&r1=1.2685.2.114.2.8.2.31&r2=1.2685.2.114.2.8.2.32
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/pt.c.diff?cvsroot=gcc&only_with_tag=gcc-3_2-rhl8-branch&r1=1.578.2.11.4.9&r2=1.578.2.11.4.10
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_2-rhl8-branch&r1=1.1672.2.166.2.8.2.90&r2=1.1672.2.166.2.8.2.91
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/friend20.C.diff?cvsroot=gcc&only_with_tag=gcc-3_2-rhl8-branch&r1=NONE&r2=1.1.80.1