https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80662
Jonathan Wakely <redi at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Component|libstdc++ |c++ --- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> --- And further: namespace std { struct ostream { ostream& operator<<(const char*) { return *this; } }; #ifndef UNCONSTRAINED // GCC 7 code template<typename _Ostream, typename _Tp> inline ostream& operator<<(_Ostream&& __os, const _Tp&__x) { return __os; } #else // GCC 6 code template<typename _Tp> inline ostream& operator<<(ostream&& __os, const _Tp&) { return __os; } #endif } struct my_stream : public std::ostream { template<typename T> my_stream& operator<<(T&& value) { std::ostream::operator<<(value); return *this; } }; int main() { my_stream& s = (my_stream{} << "hello world"); } G++ chooses std::operator<< Clang chooses my_stream::operator<< EDG and VC++ say they're ambiguous. Changing to component=c++, but I'm not convinced G++ is actually wrong here.