This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

c++/4793: friend template to a template class is not recognized as friend



>Number:         4793
>Category:       c++
>Synopsis:       friend template to a template class is not recognized as friend
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          rejects-legal
>Submitter-Id:   net
>Arrival-Date:   Mon Nov 05 10:36:00 PST 2001
>Closed-Date:
>Last-Modified:
>Originator:     js
>Release:        gcc-3.0.1, but also affects previous releases
>Organization:
>Environment:
RedHat Linux 2.4.10
>Description:
There is a template class and a friend function that takes also a second template parameter. The compiler doesn't recognize the function as friend and gives 'private member' errors.
>How-To-Repeat:

#include <iostream.h>

template <class T,class S> int f(T a,S b); // forward declaration

template <class T>
class classA
{
	template <class S> friend int f(T a,S b);
	private:
		T a;
	
	public:
		classA(T _a):a(_a) { }
};

template <class T,class S>
int f(T a,S b)
{
	return a.a+b;
}

int main()
{
	classA<int> a(5);

	cout<<f(a,3)<<endl;
	
	return 0;
}

>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]