mirror of git://gcc.gnu.org/git/gcc.git
Fix construction of std::function from null pointer-to-member
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: r239205
This commit is contained in:
parent
1fdb895a9d
commit
60a1663f22
|
|
@ -1,5 +1,14 @@
|
||||||
2016-08-06 Jonathan Wakely <jwakely@redhat.com>
|
2016-08-06 Jonathan Wakely <jwakely@redhat.com>
|
||||||
|
|
||||||
|
Backport from mainline
|
||||||
|
2016-01-18 Jonathan Wakely <jwakely@redhat.com>
|
||||||
|
|
||||||
|
PR libstdc++/69243
|
||||||
|
* 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.
|
||||||
|
|
||||||
* doc/xml/manual/status_cxx2011.xml: Change "mainline GCC SVN" to
|
* doc/xml/manual/status_cxx2011.xml: Change "mainline GCC SVN" to
|
||||||
refer to the release series.
|
refer to the release series.
|
||||||
* doc/xml/manual/status_cxx2014.xml: Likewise.
|
* doc/xml/manual/status_cxx2014.xml: Likewise.
|
||||||
|
|
|
||||||
|
|
@ -1764,13 +1764,13 @@ _GLIBCXX_MEM_FN_TRAITS(&&, false_type, true_type)
|
||||||
|
|
||||||
template<typename _Tp>
|
template<typename _Tp>
|
||||||
static bool
|
static bool
|
||||||
_M_not_empty_function(_Tp* const& __fp)
|
_M_not_empty_function(_Tp* __fp)
|
||||||
{ return __fp; }
|
{ return __fp != nullptr; }
|
||||||
|
|
||||||
template<typename _Class, typename _Tp>
|
template<typename _Class, typename _Tp>
|
||||||
static bool
|
static bool
|
||||||
_M_not_empty_function(_Tp _Class::* const& __mp)
|
_M_not_empty_function(_Tp _Class::* __mp)
|
||||||
{ return __mp; }
|
{ return __mp != nullptr; }
|
||||||
|
|
||||||
template<typename _Tp>
|
template<typename _Tp>
|
||||||
static bool
|
static bool
|
||||||
|
|
|
||||||
|
|
@ -15,17 +15,33 @@
|
||||||
// with this library; see the file COPYING3. If not see
|
// with this library; see the file COPYING3. If not see
|
||||||
// <http://www.gnu.org/licenses/>.
|
// <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
// libstdc++/57465
|
|
||||||
|
|
||||||
// { dg-options "-std=gnu++11" }
|
// { dg-options "-std=gnu++11" }
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <testsuite_hooks.h>
|
#include <testsuite_hooks.h>
|
||||||
|
|
||||||
int main()
|
void test01()
|
||||||
{
|
{
|
||||||
using F = void();
|
using F = void();
|
||||||
F* f = nullptr;
|
F* f = nullptr;
|
||||||
std::function<F> x(f);
|
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();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue