From: Paolo Carlini Date: Wed, 25 Mar 2015 12:55:22 +0000 (+0000) Subject: re PR libstdc++/65543 (rvalue stream insertion and extraction operators incorrectly... X-Git-Tag: releases/gcc-4.8.5~198 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f0b02605995bd7bf8124857680bbf93fd7e9a6d1;p=thirdparty%2Fgcc.git re PR libstdc++/65543 (rvalue stream insertion and extraction operators incorrectly implemented) 2015-03-25 Paolo Carlini PR libstdc++/65543 * include/std/istream (operator>>(basic_istream<>&&, _Tp&): Revert thinko in r150387. * include/std/ostream (operator<<(basic_ostream<>&&, const _Tp&): Likewise. * testsuite/27_io/rvalue_streams-2.cc: New. From-SVN: r221664 --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index b266521bc95e..019a8c40fb7c 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,12 @@ +2015-03-25 Paolo Carlini + + PR libstdc++/65543 + * include/std/istream (operator>>(basic_istream<>&&, _Tp&): Revert + thinko in r150387. + * include/std/ostream (operator<<(basic_ostream<>&&, const _Tp&): + Likewise. + * testsuite/27_io/rvalue_streams-2.cc: New. + 2015-01-09 Jonathan Wakely PR libstdc++/60966 diff --git a/libstdc++-v3/include/std/istream b/libstdc++-v3/include/std/istream index 861bca53adf3..6e72c94e0691 100644 --- a/libstdc++-v3/include/std/istream +++ b/libstdc++-v3/include/std/istream @@ -870,7 +870,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template inline basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>&& __is, _Tp& __x) - { return (__is >> __x); } + { + __is >> __x; + return __is; + } #endif // C++11 _GLIBCXX_END_NAMESPACE_VERSION diff --git a/libstdc++-v3/include/std/ostream b/libstdc++-v3/include/std/ostream index e466b54e78a9..f3581b8bb11b 100644 --- a/libstdc++-v3/include/std/ostream +++ b/libstdc++-v3/include/std/ostream @@ -600,7 +600,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template inline basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>&& __os, const _Tp& __x) - { return (__os << __x); } + { + __os << __x; + return __os; + } #endif // C++11 _GLIBCXX_END_NAMESPACE_VERSION diff --git a/libstdc++-v3/testsuite/27_io/rvalue_streams-2.cc b/libstdc++-v3/testsuite/27_io/rvalue_streams-2.cc new file mode 100644 index 000000000000..d9b61464b580 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/rvalue_streams-2.cc @@ -0,0 +1,35 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2015 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include + +struct A {}; + +void operator<<(std::ostream&, const A&) { } +void operator>>(std::istream&, A&) { } + +// PR libstdc++/65543 +int main() +{ + A a; + + std::ostringstream() << a; + std::istringstream() >> a; +}