This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Template friend bug in gcc-2.95
- To: egcs-bugs at egcs dot cygnus dot com
- Subject: Template friend bug in gcc-2.95
- From: Hyman Rosen <hymie at jyacc dot com>
- Date: Wed, 16 Jun 1999 13:04:51 -0400
In the following code, the snapshot gcc-2.95 19990615
fails trying to construct AAA<int> a1 with the error
In method `AAA<int>::AAA()':
14: instantiated from here
8: `CCC<int>::CCC(int)' is private
10: within this context
even though CCC has declared that class AAA<int> is a friend.
template <typename T1> struct AAA { AAA(); };
template <typename T1> void FFF();
template <typename T1>
class CCC
{
friend class AAA<int>;
friend void FFF<int>();
CCC(T1 t1) { }
};
template <typename T1> AAA<T1>::AAA() { static_cast<void>(CCC<T1>(T1())); }
template <typename T1> void FFF() { static_cast<void>(CCC<T1>(T1())); }
int main ()
{
AAA<int> a1; // This should work, but doesn't
AAA<char> a2; // This shouldn't work, and doesn't
FFF<int>(); // This should work, and does
FFF<char>(); // This shouldn't work, and doesn't
}