aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Kosnik <bkoz@redhat.com>2009-05-27 20:32:30 +0000
committerBenjamin Kosnik <bkoz@gcc.gnu.org>2009-05-27 20:32:30 +0000
commit626e0599af96df36ac6b847349a33948d7bb3f7e (patch)
treed99980c516af84be2d033dd11a9de54c70f5c509
parent667e6f892412bcd32deb79ebfb8d41e211e9cbed (diff)
downloadgcc-626e0599af96df36ac6b847349a33948d7bb3f7e.zip
gcc-626e0599af96df36ac6b847349a33948d7bb3f7e.tar.gz
gcc-626e0599af96df36ac6b847349a33948d7bb3f7e.tar.bz2
re PR libstdc++/40273 ([C++0x] Invalid conversion to bool is reported)
2009-05-27 Benjamin Kosnik <bkoz@redhat.com> PR libstdc++/40273 * include/tr1_impl/functional: Add explicit cast. * testsuite/20_util/function/requirements/ explicit_instantiation.cc: New. * testsuite/20_util/function/null_pointer_comparisons.cc: New. From-SVN: r147930
-rw-r--r--libstdc++-v3/ChangeLog10
-rw-r--r--libstdc++-v3/include/tr1_impl/functional10
-rw-r--r--libstdc++-v3/testsuite/20_util/function/null_pointer_comparisons.cc44
-rw-r--r--libstdc++-v3/testsuite/20_util/function/requirements/explicit_instantiation.cc26
4 files changed, 84 insertions, 6 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 5f54296..1f7be0f 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,5 +1,13 @@
+2009-05-27 Benjamin Kosnik <bkoz@redhat.com>
+
+ PR libstdc++/40273
+ * include/tr1_impl/functional: Add explicit cast.
+ * testsuite/20_util/function/requirements/
+ explicit_instantiation.cc: New.
+ * testsuite/20_util/function/null_pointer_comparisons.cc: New.
+
2009-05-24 Eelis van der Weegen <eelis@eelis.net>
-
+
* libsupc++/initializer_list (initializer_list): Add missing typedefs.
2009-05-21 Benjamin Kosnik <bkoz@redhat.com>
diff --git a/libstdc++-v3/include/tr1_impl/functional b/libstdc++-v3/include/tr1_impl/functional
index 980061d..584a403 100644
--- a/libstdc++-v3/include/tr1_impl/functional
+++ b/libstdc++-v3/include/tr1_impl/functional
@@ -1557,7 +1557,7 @@ _GLIBCXX_BEGIN_NAMESPACE_TR1
template<typename _Signature>
static bool
_M_not_empty_function(const function<_Signature>& __f)
- { return __f; }
+ { return static_cast<bool>(__f); }
template<typename _Tp>
static bool
@@ -2095,13 +2095,13 @@ _GLIBCXX_BEGIN_NAMESPACE_TR1
template<typename _Signature>
inline bool
operator==(const function<_Signature>& __f, _M_clear_type*)
- { return !__f; }
+ { return !static_cast<bool>(__f); }
/// @overload
template<typename _Signature>
inline bool
operator==(_M_clear_type*, const function<_Signature>& __f)
- { return !__f; }
+ { return !static_cast<bool>(__f); }
/**
* @brief Compares a polymorphic function object wrapper against 0
@@ -2113,13 +2113,13 @@ _GLIBCXX_BEGIN_NAMESPACE_TR1
template<typename _Signature>
inline bool
operator!=(const function<_Signature>& __f, _M_clear_type*)
- { return __f; }
+ { return static_cast<bool>(__f); }
/// @overload
template<typename _Signature>
inline bool
operator!=(_M_clear_type*, const function<_Signature>& __f)
- { return __f; }
+ { return static_cast<bool>(__f); }
// [3.7.2.8] specialized algorithms
diff --git a/libstdc++-v3/testsuite/20_util/function/null_pointer_comparisons.cc b/libstdc++-v3/testsuite/20_util/function/null_pointer_comparisons.cc
new file mode 100644
index 0000000..7f446d7
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/function/null_pointer_comparisons.cc
@@ -0,0 +1,44 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-do compile }
+
+// Copyright (C) 2009 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
+// <http://www.gnu.org/licenses/>.
+
+#include <functional>
+
+// libstdc++/40273
+int main()
+{
+ std::function<void* ()> f = 0;
+ if (f != 0)
+ {
+ }
+
+ if (0 != f)
+ {
+ }
+
+ if (f == 0)
+ {
+ }
+
+ if (0 == f)
+ {
+ }
+ return 0;
+}
+
diff --git a/libstdc++-v3/testsuite/20_util/function/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/20_util/function/requirements/explicit_instantiation.cc
new file mode 100644
index 0000000..dbd8be6
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/function/requirements/explicit_instantiation.cc
@@ -0,0 +1,26 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-do compile }
+
+// Copyright (C) 2009 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
+// <http://www.gnu.org/licenses/>.
+
+#include <functional>
+
+namespace std
+{
+ template class function<void* ()>;
+}