[Bug libstdc++/65543] New: rvalue stream insertion and extraction operators incorrectly implemented
rs2740 at gmail dot com
gcc-bugzilla@gcc.gnu.org
Tue Mar 24 17:41:00 GMT 2015
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.
More information about the Gcc-bugs
mailing list