aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Smith-Rowland <3dw4rd@verizon.net>2013-02-07 14:27:45 +0000
committerEdward Smith-Rowland <emsr@gcc.gnu.org>2013-02-07 14:27:45 +0000
commitfcf0430bda26a50f1279cb09e8bd8ecfdfa687d6 (patch)
tree8b380f6dd04c8f86fff867df6b7476c0aafed0a1
parent3e508131146912f5ce41b11b70989049505c6fba (diff)
downloadgcc-fcf0430bda26a50f1279cb09e8bd8ecfdfa687d6.zip
gcc-fcf0430bda26a50f1279cb09e8bd8ecfdfa687d6.tar.gz
gcc-fcf0430bda26a50f1279cb09e8bd8ecfdfa687d6.tar.bz2
PR56193 - Wrong test operator for basic_ios in C++11.
From-SVN: r195849
-rw-r--r--libstdc++-v3/ChangeLog6
-rw-r--r--libstdc++-v3/include/bits/basic_ios.h5
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_ios/pr56193.cc15
3 files changed, 26 insertions, 0 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index a898d77..3cc1eec 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,9 @@
+2013-02-06 Edward Smith-Rowland <3dw4rd@verizon.net>
+
+ * include/bits/basic_ios.h: Replace operator void*() const
+ with explicit operator bool() const in C++11 and greater.
+ * testsuite/27_io/basic_ios/pr56193.cc: New file.
+
2013-02-04 Dodji Seketeli <dodji@redhat.com>
Add missing explicit instantiation for std::lower_bound template
diff --git a/libstdc++-v3/include/bits/basic_ios.h b/libstdc++-v3/include/bits/basic_ios.h
index b78b464..bda40f0 100644
--- a/libstdc++-v3/include/bits/basic_ios.h
+++ b/libstdc++-v3/include/bits/basic_ios.h
@@ -112,8 +112,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* This allows you to write constructs such as
* <code>if (!a_stream) ...</code> and <code>while (a_stream) ...</code>
*/
+#if __cplusplus >= 201103L
+ explicit operator bool() const
+ { return !this->fail(); }
+#else
operator void*() const
{ return this->fail() ? 0 : const_cast<basic_ios*>(this); }
+#endif
bool
operator!() const
diff --git a/libstdc++-v3/testsuite/27_io/basic_ios/pr56193.cc b/libstdc++-v3/testsuite/27_io/basic_ios/pr56193.cc
new file mode 100644
index 0000000..48c9582
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_ios/pr56193.cc
@@ -0,0 +1,15 @@
+// { dg-do compile }
+// { dg-options "-std=gnu++11" }
+// Copyright (C) 2013 Free Software Foundation, Inc.
+
+#include <iostream>
+
+// PR libstdc++/56193
+
+int
+test01()
+{
+ std::cout << std::cout; // { dg-error "cannot bind" }
+}
+
+// { dg-error "initializing argument" "" { target *-*-* } 602 }