]> gcc.gnu.org Git - gcc.git/commitdiff
re PR libstdc++/40273 ([C++0x] Invalid conversion to bool is reported)
authorBenjamin Kosnik <bkoz@redhat.com>
Wed, 27 May 2009 20:32:30 +0000 (20:32 +0000)
committerBenjamin Kosnik <bkoz@gcc.gnu.org>
Wed, 27 May 2009 20:32:30 +0000 (20:32 +0000)
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

libstdc++-v3/ChangeLog
libstdc++-v3/include/tr1_impl/functional
libstdc++-v3/testsuite/20_util/function/null_pointer_comparisons.cc [new file with mode: 0644]
libstdc++-v3/testsuite/20_util/function/requirements/explicit_instantiation.cc [new file with mode: 0644]

index 5f54296bb059ff514e8c48fdc92f7003c2ea1af8..1f7be0f251b9b51b71ce3d00718f8410891e267d 100644 (file)
@@ -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>
index 980061d69027c003412ff6e86e4de69e2db70d42..584a403de487f09ad335d7bdb41ed03393411671 100644 (file)
@@ -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 (file)
index 0000000..7f446d7
--- /dev/null
@@ -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 (file)
index 0000000..dbd8be6
--- /dev/null
@@ -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* ()>;
+}
This page took 0.086626 seconds and 5 git commands to generate.