]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Fix construction of std::function from null pointer-to-member
authorJonathan Wakely <jwakely@redhat.com>
Mon, 18 Jan 2016 11:43:37 +0000 (11:43 +0000)
committerJonathan Wakely <redi@gcc.gnu.org>
Mon, 18 Jan 2016 11:43:37 +0000 (11:43 +0000)
PR libstdc++/69293
* include/std/functional (_Function_base::_M_not_empty_function):
Change overloads for pointers to take arguments by value.
* testsuite/20_util/function/cons/57465.cc: Add tests for
pointer-to-member cases.

From-SVN: r232504

libstdc++-v3/ChangeLog
libstdc++-v3/include/std/functional
libstdc++-v3/testsuite/20_util/function/cons/57465.cc

index 74ef4f61eab5290f3f3854fa194b3fa3356da7d9..787bcd719ca57e13b07e69d3b8ee9465f994031f 100644 (file)
@@ -1,5 +1,11 @@
 2016-01-18  Jonathan Wakely  <jwakely@redhat.com>
 
+       PR libstdc++/69293
+       * include/std/functional (_Function_base::_M_not_empty_function):
+       Change overloads for pointers to take arguments by value.
+       * testsuite/20_util/function/cons/57465.cc: Add tests for
+       pointer-to-member cases.
+
        PR libstdc++/69340
        * src/c++11/cow-stdexcept.cc (_txnal_cow_string_C1_for_exceptions):
        Use macros for exception handling and fix unused parameter warning.
index 557156a358c32653e4513955ab9682fe35e76174..979941072ba3805b63b3b08ec14a96cc508dc0f8 100644 (file)
@@ -1633,13 +1633,13 @@ _GLIBCXX_MEM_FN_TRAITS(&&, false_type, true_type)
 
        template<typename _Tp>
          static bool
-         _M_not_empty_function(_Tp* const& __fp)
-         { return __fp; }
+         _M_not_empty_function(_Tp* __fp)
+         { return __fp != nullptr; }
 
        template<typename _Class, typename _Tp>
          static bool
-         _M_not_empty_function(_Tp _Class::* const& __mp)
-         { return __mp; }
+         _M_not_empty_function(_Tp _Class::* __mp)
+         { return __mp != nullptr; }
 
        template<typename _Tp>
          static bool
index be2d13272a59d074a727728c44bfdb08f3895370..7b13d4b285b00b429ad2579dbc0c42cf07c366eb 100644 (file)
 // with this library; see the file COPYING3.  If not see
 // <http://www.gnu.org/licenses/>.
 
-// libstdc++/57465
-
 // { dg-options "-std=gnu++11" }
 
 #include <functional>
 #include <testsuite_hooks.h>
 
-int main()
+void test01()
 {
   using F = void();
   F* f = nullptr;
   std::function<F> x(f);
-  VERIFY( !x );
+  VERIFY( !x ); // libstdc++/57465
+}
+
+void test02()
+{
+  struct X { };
+  int (X::*mf)() = nullptr;
+  std::function<int(X&)> f = mf;
+  VERIFY( !f ); // libstdc++/69243
+
+  int X::*mp = nullptr;
+  f = mp;
+  VERIFY( !f );
+}
+
+int main()
+{
+  test01();
+  test02();
 }