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); }
Fix: I do not know.
State-Changed-From-To: open->analyzed State-Changed-Why: Confirmed.
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
It did not ICE in 2.91.66 so this is a regresion but an old one thogugh.
Fixed in GCC 3.4 as of 2003-07-13.
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
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
Fixed in GCC 3.3.1, GCC 3.4.
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
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