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]

Bug (?) in namespaces and overloading resolution


Hi,

The following code does not compile on 19980604, I believe it should.
It works if the defintion of struct X is moved into namespace B.
The error messages reported are:

egcs/njs3-bug-9.cc: In function `struct C::Y & operator <<<A::X>(struct C::Y &, const struct A::X &)':
egcs/njs3-bug-9.cc:43:   instantiated from here
egcs/njs3-bug-9.cc:27: no match for `_IO_ostream_withassign & << const A::X &'
/homes/njs3/pub/cc/egcs-980604/include/g++/iostream.h:77: candidates are: ostream::operator <<(char)
/homes/njs3/pub/cc/egcs-980604/include/g++/iostream.h:78:                 ostream::operator <<(unsigned char)
[snip]
/homes/njs3/pub/cc/egcs-980604/include/g++/iostream.h:108:                 ostream::operator <<(streambuf *)
egcs/njs3-bug-9.cc:26:                 operator <<<A::X>(C::Y &, const A::X &)

Please CC me on any response, thanks.


#include <iostream.h>

using namespace std;

namespace A {
	struct X { };	
}

namespace B {

	using A::X;

	inline ostream& operator<<(ostream& ostr, const X& x)
	{
		return ostr;
	}
	
};

namespace C {

	struct Y { };
	
	template<class T>
	Y& operator<<(Y& y, const T& t)
	{
		cerr << t;
		return y;
	}
	
};

using namespace B;
using namespace C;


int
main()
{
	X	x;
	Y	y;
	
	y << x;
}


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