From 99ebfe90756a3bd3c94828c56a102f886b919673 Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Sat, 11 Feb 2017 21:08:11 +0000 Subject: [PATCH] PR libstdc++/79467 use lvalues in is_callable check 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. From-SVN: r245363 --- libstdc++-v3/ChangeLog | 6 +++++ libstdc++-v3/include/bits/shared_ptr_base.h | 4 ++-- .../testsuite/20_util/shared_ptr/cons/79467.cc | 27 ++++++++++++++++++++++ 3 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 libstdc++-v3/testsuite/20_util/shared_ptr/cons/79467.cc diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 0f6de92eeb4..4f5656bf867 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,5 +1,11 @@ 2017-02-11 Jonathan Wakely + 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 diff --git a/libstdc++-v3/include/bits/shared_ptr_base.h b/libstdc++-v3/include/bits/shared_ptr_base.h index 3b8a5c7fad4..770a0948d40 100644 --- a/libstdc++-v3/include/bits/shared_ptr_base.h +++ b/libstdc++-v3/include/bits/shared_ptr_base.h @@ -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 index 00000000000..bcf96548307 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/shared_ptr/cons/79467.cc @@ -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 +// . + +// { dg-do compile { target c++11 } } + +#include + +struct D { + void operator()(int*&) & {} // PR libstdc++/79467 +}; + +std::shared_ptr p(new int, D()); +std::shared_ptr q(new int, D(), std::allocator()); -- 2.11.4.GIT