Original-Message-Id: <199908081039.MAA26290@mpii01807.ag1.mpi-sb.mpg.de> Date: Sun, 08 Aug 1999 12:39:35 +0200 There seems to be a problem with specialised template friend functions in a class template when there are also member functions with the same name. The requested info for a bug report is below. (I have the same problem under Linux on my notebook - so this seems to be platform independent; the same problem arises if namespace is not used; the same problems arises if instead of operator- we have plain functions). Thanks. g++ -v --save-temps specialized_template_friend_member_function_overload_problem.C --- Reading specs from /KM/usr/naeher/gcc-2.95/lib/gcc-lib/sparc-sun-solaris2.6/2.95/specs gcc version 2.95 19990728 (release) /KM/usr/naeher/gcc-2.95/lib/gcc-lib/sparc-sun-solaris2.6/2.95/cpp -lang-c++ -v -D__GNUC__=2 -D__GNUG__=2 -D__GNUC_MINOR__=95 -D__cplusplus -Dsparc -Dsun -Dunix -D__svr4__ -D__SVR4 -D__sparc__ -D__sun__ -D__unix__ -D__svr4__ -D__SVR4 -D__sparc -D__sun -D__unix -Asystem(unix) -Asystem(svr4) -D__EXCEPTIONS -D__GCC_NEW_VARARGS__ -Acpu(sparc) -Amachine(sparc) specialized_template_friend_member_function_overload_problem.C specialized_template_friend_member_function_overload_problem.ii GNU CPP version 2.95 19990728 (release) (sparc) #include "..." search starts here: #include <...> search starts here: /KM/usr/naeher/gcc-2.95/lib/gcc-lib/sparc-sun-solaris2.6/2.95/../../../../include/g++-3 /KM/usr/naeher/gcc-2.95/include /KM/usr/naeher/gcc-2.95/lib/gcc-lib/sparc-sun-solaris2.6/2.95/../../../../sparc-sun-solaris2.6/include /KM/usr/naeher/gcc-2.95/lib/gcc-lib/sparc-sun-solaris2.6/2.95/include /usr/include End of search list. The following default directories have been omitted from the search path: End of omitted list. /KM/usr/naeher/gcc-2.95/lib/gcc-lib/sparc-sun-solaris2.6/2.95/cc1plus specialized_template_friend_member_function_overload_problem.ii -quiet -dumpbase specialized_template_friend_member_function_overload_problem.cc -version -o specialized_template_friend_member_function_overload_problem.s GNU C++ version 2.95 19990728 (release) (sparc-sun-solaris2.6) compiled by GNU C version 2.7.2.3. specialized_template_friend_member_function_overload_problem.C: In instantiation of `CGAL::V<double>': specialized_template_friend_member_function_overload_problem.C:54: instantiated from here specialized_template_friend_member_function_overload_problem.C:31: invalid use of undefined type `class CGAL::V<double>' specialized_template_friend_member_function_overload_problem.C:33: forward declaration of `class CGAL::V<double>' specialized_template_friend_member_function_overload_problem.C:31: confused by earlier errors, bailing out --- specialized_template_friend_member_function_overload_problem.ii: # 1 "specialized_template_friend_member_function_overload_problem.C" namespace CGAL{ template <class T> class P; template <class T> class V; class O {}; template <class T> V<T> operator-( const P<T>&, const O& ); template <class T> class P { T _a; P( const V<T>& v) : _a(v.x()) {} public: P( const T& a) : _a(a) {} T x() { return _a; } }; template <class T> class V { T _b; V( const P<T>& p) : _b(p.x()) {} public: V( const T& a) : _b(a) {} V<T> operator-(); friend V<T> operator-<>( const P<T>& a, const O& ); T x() { return _b; } }; template <class T> V<T> operator-( const P<T>& p, const O& ) { return V<T>( p); } template <class T> V<T> V<T>::operator-() { return V<T>( -_b); } } int main() { CGAL::P<double> a(1.0); CGAL::V<double> b(1.0); return 0; } Release: 2.95.2
State-Changed-From-To: open->analyzed State-Changed-Why: Confirmed as a bug
From: loewis@gcc.gnu.org To: gcc-gnats@gcc.gnu.org, martin@loewis.home.cs.tu-berlin.de, nobody@gcc.gnu.org, stschirr@mpi-sb.mpg.de Cc: Subject: Re: c++/43 Date: 9 Mar 2000 07:28:14 -0000 Old Synopsis: [not accepted] friend operators New Synopsis: friend operators State-Changed-From-To: open->analyzed State-Changed-By: loewis State-Changed-When: Wed Mar 8 23:28:14 2000 State-Changed-Why: Confirmed as a bug http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view&pr=43&database=gcc
Responsible-Changed-From-To: unassigned->nathan Responsible-Changed-Why: patch in progress
From: nathan@gcc.gnu.org To: gcc-gnats@gcc.gnu.org, martin@loewis.home.cs.tu-berlin.de, nathan@gcc.gnu.org, nobody@gcc.gnu.org, stschirr@mpi-sb.mpg.de Cc: Subject: Re: c++/43 Date: 20 Nov 2000 14:23:14 -0000 Synopsis: friend operators Responsible-Changed-From-To: unassigned->nathan Responsible-Changed-By: nathan Responsible-Changed-When: Mon Nov 20 06:23:14 2000 Responsible-Changed-Why: patch in progress http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view&pr=43&database=gcc
State-Changed-From-To: analyzed->closed State-Changed-Why: 2000-11-27 Nathan Sidwell <nathan@codesourcery.com> * decl.c (grokfndecl): Undo COMPONENT_REF damage caused by bison parser ickiness. * pt.c (tsubst_friend_function): Enter namespace scope when tsubsting the function name. * cp-tree.h (DECL_TI_TEMPLATE): Update comment to reflect reality. 2000-11-27 Nathan Sidwell <nathan@codesourcery.com> * g++.old-deja/g++.other/friend46.C: New test.
From: nathan@gcc.gnu.org To: gcc-gnats@gcc.gnu.org, martin@loewis.home.cs.tu-berlin.de, nathan@gcc.gnu.org, stschirr@mpi-sb.mpg.de Cc: Subject: Re: c++/43 Date: 27 Nov 2000 12:56:30 -0000 Synopsis: friend operators State-Changed-From-To: analyzed->closed State-Changed-By: nathan State-Changed-When: Mon Nov 27 04:56:30 2000 State-Changed-Why: 2000-11-27 Nathan Sidwell <nathan@codesourcery.com> * decl.c (grokfndecl): Undo COMPONENT_REF damage caused by bison parser ickiness. * pt.c (tsubst_friend_function): Enter namespace scope when tsubsting the function name. * cp-tree.h (DECL_TI_TEMPLATE): Update comment to reflect reality. 2000-11-27 Nathan Sidwell <nathan@codesourcery.com> * g++.old-deja/g++.other/friend46.C: New test. http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view&pr=43&database=gcc