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]

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



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;
}



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