The line number in an error message with illegal is badly placed, nowhere near the offending friend declaration. Release: 3.2 Environment: System: SunOS alto 5.9 Generic sun4u sparc SUNW,Sun-Blade-1000 Architecture: sun4 host: sparc-sun-solaris2.9 build: sparc-sun-solaris2.9 target: sparc-sun-solaris2.9 configured with: ../gcc-3.2/configure --prefix=/space/bill/util --with-cpu=ultrasparc --enable-languages=c,c++,f77 How-To-Repeat: With this file: // templ-friend-bug.cc template <typename T, typename P> class X { public: X() { } private: template <typename U> friend class X; }; X<int, int> i; // end compiling with g++ 3.2 gives the following message: ? g++ -c templ-friend-bug.cc templ-friend-bug.cc: In instantiation of `X<int, int>': templ-friend-bug.cc:11: instantiated from here templ-friend-bug.cc:3: previous declaration `template<class T, class P> class X' templ-friend-bug.cc:3: used 2 template parameters instead of 1 ? the same occurs with 3.2.1 pre (20021110) and 3.3 pre (20021110) it would be nice if it mentioned line 8 somewhere in the error message (presumably the last line). it took a great deal of time to find the problem in my code with a rather large template. my original code also got an ICE in 3.3 pre, but this stripped down version didn't. i'll look into that separately.
State-Changed-From-To: open->analyzed State-Changed-Why: Confirmed. I think that this is probably related to PR 2019.
Generic C++ front-end problem.
*** Bug 12390 has been marked as a duplicate of this bug. ***
*** Bug 13390 has been marked as a duplicate of this bug. ***
Still valid in GCC 4.3
Subject: Bug 8570 Author: manu Date: Mon Nov 12 00:28:41 2007 New Revision: 130092 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=130092 Log: 2007-11-12 Manuel Lopez-Ibanez <manu@gcc.gnu.org> PR c++/8570 cp/ * pt.c (redeclare_class_template): Update error message. Use a note to show the previous declaration. (tsubst_friend_class): Use the location of the friend template as the input location before calling redeclare_class_template. testsuite/ * g++.old-deja/g++.ns/template13.C: Update expected output. * g++.old-deja/g++.pt/friend23.C: Likewise. * g++.dg/warn/pr8570.C: New. Added: trunk/gcc/testsuite/g++.dg/warn/pr8570.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/pt.c trunk/gcc/testsuite/ChangeLog trunk/gcc/testsuite/g++.old-deja/g++.ns/template13.C trunk/gcc/testsuite/g++.old-deja/g++.pt/friend23.C
Fixed in GCC 4.3
Subject: Bug number PR c++/8570 A patch for this bug has been added to the patch tracker. The mailing list url for the patch is http://gcc.gnu.org/ml/gcc-patches/2007-11/msg00581.html