This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
c++/4793: friend template to a template class is not recognized as friend
- To: gcc-gnats at gcc dot gnu dot org
- Subject: c++/4793: friend template to a template class is not recognized as friend
- From: jagol-8jy3oxpJJ at suckfuell dot net
- Date: 5 Nov 2001 18:31:55 -0000
- Reply-To: jagol-8jy3oxpJJ at suckfuell dot net
>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: