OSDN Git Service

2009-05-27 Benjamin Kosnik <bkoz@redhat.com>
authorbkoz <bkoz@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 27 May 2009 20:32:30 +0000 (20:32 +0000)
committerbkoz <bkoz@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 27 May 2009 20:32:30 +0000 (20:32 +0000)
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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@147930 138bc75d-0d04-0410-961f-82ee72b054a4

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 5f54296..1f7be0f 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 980061d..584a403 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* ()>;
+}