]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
PR libstdc++/79467 use lvalues in is_callable check
authorredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 11 Feb 2017 21:08:11 +0000 (21:08 +0000)
committerredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 11 Feb 2017 21:08:11 +0000 (21:08 +0000)
PR libstdc++/79467
* include/bits/shared_ptr_base.h (__shared_ptr(_Yp*, _Deleter))
(__shared_ptr(_Yp*, _Deleter, _Alloc)): Use lvalue types in
__is_callable check.
* testsuite/20_util/shared_ptr/cons/79467.cc: New.

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

libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/shared_ptr_base.h
libstdc++-v3/testsuite/20_util/shared_ptr/cons/79467.cc [new file with mode: 0644]

index 0f6de92eeb463bbff3c3371c30e5b339dd89eaaa..4f5656bf867b8be4cf694f5a563a0a10ed994e73 100644 (file)
@@ -1,5 +1,11 @@
 2017-02-11  Jonathan Wakely  <jwakely@redhat.com>
 
+       PR libstdc++/79467
+       * include/bits/shared_ptr_base.h (__shared_ptr(_Yp*, _Deleter))
+       (__shared_ptr(_Yp*, _Deleter, _Alloc)): Use lvalue types in
+       __is_callable check.
+       * testsuite/20_util/shared_ptr/cons/79467.cc: New.
+
        * include/bits/atomic_base.h: Re-indent.
 
 2017-02-10  Gerald Pfeifer  <gerald@pfeifer.com> 
index 3b8a5c7fad4100bb2216b3f6ee00c6f6e79e86d9..770a0948d4036fec578c39b477d746eb6817c67b 100644 (file)
@@ -1085,7 +1085,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        __shared_ptr(_Yp* __p, _Deleter __d)
        : _M_ptr(__p), _M_refcount(__p, __d)
        {
-         static_assert(__is_callable<_Deleter(_Yp*)>::value,
+         static_assert(__is_callable<_Deleter&(_Yp*&)>::value,
              "deleter expression d(p) is well-formed");
          _M_enable_shared_from_this_with(__p);
        }
@@ -1095,7 +1095,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        __shared_ptr(_Yp* __p, _Deleter __d, _Alloc __a)
        : _M_ptr(__p), _M_refcount(__p, __d, std::move(__a))
        {
-         static_assert(__is_callable<_Deleter(_Yp*)>::value,
+         static_assert(__is_callable<_Deleter&(_Yp*&)>::value,
              "deleter expression d(p) is well-formed");
          _M_enable_shared_from_this_with(__p);
        }
diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/cons/79467.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/cons/79467.cc
new file mode 100644 (file)
index 0000000..bcf9654
--- /dev/null
@@ -0,0 +1,27 @@
+// Copyright (C) 2017 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/>.
+
+// { dg-do compile { target c++11 } }
+
+#include <memory>
+
+struct D {
+  void operator()(int*&) & {} // PR libstdc++/79467
+};
+
+std::shared_ptr<int> p(new int, D());
+std::shared_ptr<int> q(new int, D(), std::allocator<int>());