On 13/12/17 18:42 +0000, Jonathan Wakely wrote:
The bug here is that we called putback even if the initial __is >> __ch
extraction failed and set eofbit, and putback clears the eofbit. I
found a number of other problems though, such as not even trying to
call putback after failing to find the ',' and ')' characters.
I decided to rewrite the function following the proposed resolution
for https://wg21.link/lwg2714 which is a much more precise
specification for much more desirable semantics.
PR libstdc++/59568
* include/std/complex (operator>>): Implement proposed resolution to
LWG 2714. Use putback if and only if a character has been successfully
extracted but isn't a delimiter. Use ctype::widen and traits::eq when
testing if extracted characters match delimiters.
* testsuite/26_numerics/complex/dr2714.cc: New test.
Tested powerpc64le-linux, committed to trunk.
Here's a tweak for the testcase. Tested x86_64-linux, committed to trunk.
commit 4b8abc556e9ae9d4ff76f0b446eadf4a6f216638
Author: Jonathan Wakely <jwak...@redhat.com>
Date: Wed Dec 13 19:47:19 2017 +0000
Improve std::complex test and move to sub-directory
* testsuite/26_numerics/complex/dr2714.cc: Move to ...
* testsuite/26_numerics/complex/inserters_extractors/char/dr2714.cc:
... Here. Remove duplicate header and dg-options. Check first invalid
character gets putback. Remove wchar_t test.
diff --git a/libstdc++-v3/testsuite/26_numerics/complex/dr2714.cc b/libstdc++-v3/testsuite/26_numerics/complex/inserters_extractors/char/dr2714.cc
similarity index 92%
rename from libstdc++-v3/testsuite/26_numerics/complex/dr2714.cc
rename to libstdc++-v3/testsuite/26_numerics/complex/inserters_extractors/char/dr2714.cc
+++ b/libstdc++-v3/testsuite/26_numerics/complex/inserters_extractors/char/dr2714.cc
@@ -15,11 +15,8 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
-// { dg-options "-std=gnu++98" }
-
#include <complex>
#include <sstream>
-#include <complex>
#include <testsuite_hooks.h>
void
@@ -37,16 +34,6 @@ test01()
void
test02()
{
- std::wistringstream in(L" ( 2.0 , 0.5 ) ");
- std::complex<double> c;
- in >> c;
- VERIFY( in.good() );
- VERIFY( c.real() == 2.0 && c.imag() == 0.5 );
-}
-
-void
-test03()
-{
std::istringstream in;
std::complex<double> c(-1, -1);
const std::complex<double> c0 = c;
@@ -55,6 +42,7 @@ test03()
in >> c;
VERIFY( in.fail() );
in.clear();
+ VERIFY( in.get() == 'a' );
in.str(" ( ) ");
in >> c;
@@ -71,11 +59,10 @@ test03()
in.str("(b)");
in >> c;
VERIFY( in.fail() );
-
in.clear();
VERIFY( in.get() == 'b' );
- in.str("( c)");
+ in.str("( c)");
in >> c;
VERIFY( in.fail() );
in.clear();
@@ -121,7 +108,7 @@ test03()
}
void
-test04()
+test03()
{
// PR libstdc++/59568
std::istringstream in;
@@ -164,5 +151,4 @@ main()
test01();
test02();
test03();
- test04();
}