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]

Template friend bug in gcc-2.95


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
}


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