From: Paolo Carlini Date: Wed, 25 Mar 2015 12:55:04 +0000 (+0000) Subject: re PR libstdc++/65543 (rvalue stream insertion and extraction operators incorrectly... X-Git-Tag: releases/gcc-4.9.3~249 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0e999fe672f3dd10cc9526c5cd4d144d5d98a4c0;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: r221663 --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 3c8b9e812630..b2819101d391 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-02-03 Tim Shen PR libstdc++/64680 diff --git a/libstdc++-v3/include/std/istream b/libstdc++-v3/include/std/istream index f0637680d3b9..2b157f59a64a 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 18a56aea10cd..2f89a21dea2f 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; +}