This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
bug in g++
- To: gcc at gcc dot gnu dot org
- Subject: bug in g++
- From: "Dr. Andreas Klein" <klein at mathematik dot uni-kassel dot de>
- Date: Fri, 6 Apr 2001 11:52:50 +0200 (MET DST)
- Reply-To: "Dr. Andreas Klein" <klein at mathematik dot uni-kassel dot de>
Sorry I was not able to use GNATS.
Here is my bug report:
System: Linux
GCC-version: 2.95.2
Define a template class with a corresponding friend:
template<typename t> class A{
t a;
friend void f(A<t> x);
};
void f(A<int> x) {x.a++;};
you get a warning, but the code works. Now put the whole thing in a namespace:
namespace X {
template<typename t> class A{
t a;
friend void f(A<t> x);
};
void f(A<int> x) {x.a++;};
}
Now you get an error. f can use x.a
(`int X::A<int>::a' is private)
If you put a function declaration befor the defintion of f
namespace X {
template<typename t> class A{
t a;
friend void f(A<t> x);
};
void f(A<int> x);
void f(A<int> x) {x.a++;};
}
the code works again.
if you define f ouside the namespace
namespace X {
template<typename t> class A{
t a;
friend void f(A<t> x);
};
}
using namespace X;
void f(A<int> x) {x.a++;};
You get an Internal compiler error 378
I have no idea what is the problem.
Good bye