https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65543
Bug ID: 65543 Summary: rvalue stream insertion and extraction operators incorrectly implemented Product: gcc Version: 5.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: rs2740 at gmail dot com Repro: #include <iostream> #include <sstream> struct A{}; void operator<<(std::ostream &, A const &){ } void operator>>(std::istream &, A &){ } int main() { A a; std::ostringstream() << a; std::istringstream() >> a; return 0; } The standard says that operator<< for rvalue streams performs `os << x` and returns `os`. The libstdc++ implementation instead does return (__os << __x); which breaks if the operator<< called does not return a reference stream. A similar issue affects operator>> for rvalue streams.