New C++ frontend bug since the big template change.

Klaus-Georg Adams Klaus-Georg.Adams@chemie.uni-karlsruhe.de
Fri Jul 31 06:57:00 GMT 1998


The appended source doesn't compile any more:
friend1.C: In function `class mystream & operator >><int>(class mystream &, class a<int> &)':
friend1.C:23: member `amember' is a private member of class `a<int>'

egcs-2.91.47 didn't complain.

Note: If you leave out either the declaration of the specialization of
operator>> for int or the explicit instantiation of class a<int> the
program compiles.

-- 
-------------------------------------------------------------------------
Klaus-Georg Adams        Email: Klaus-Georg.Adams@chemie.uni-karlsruhe.de
Institut f. Anorg. Chemie, Lehrstuhl II            Tel: 49(0)721 608 3485
Universität Karlsruhe, D-76128 Karlsruhe
-------------------------------------------------------------------------
class mystream;

// Declare class template a.
template <class T> class a {
public:
	friend mystream& operator>> <>( mystream&, a<T>& thea );
private:
	T amember;
};

// Declare function template operator>>
template <class T> mystream& operator>>( mystream& s, a<T>& thea );

// Declare specialization for int.
template<> mystream& operator>> <int>( mystream& s, a<int>& thea );

// Explicit instantiation of a<int>
template class a<int>;

// Define operator>><int>
template<> mystream& operator>> <int>( mystream& s, a<int>& thea )
{
	thea.amember = 0;
	return s;
}




More information about the Gcc-bugs mailing list