[Bug c++/51577] dependent name lookup finds operator in global namespace
redi at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Mon Mar 9 10:11:00 GMT 2015
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51577
--- Comment #10 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Testcase from PR65336:
extern "C" int puts(const char*);
struct ostream {} cout;
template<typename T> struct A{ T t; };
struct B{};
struct C : public B{};
ostream& operator<< (ostream& out, const B&)
{ puts("right"); return out; }
namespace {
template<typename T>
ostream& operator<< (ostream& out, const A<T>&v)
{ return out << v.t; }
ostream& operator<< (ostream& out, const C&)
{ puts("wrong"); return out; }
}
int main(){
A<C> a;
cout << a;
}
More information about the Gcc-bugs
mailing list