From: Jonathan Wakely Date: Mon, 17 Oct 2016 17:03:19 +0000 (+0100) Subject: Use ::new to avoid finding overloaded operator new X-Git-Tag: releases/gcc-5.5.0~763 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=012ed5c2fa8904b0506129aa38667fa5b27ed24d;p=thirdparty%2Fgcc.git Use ::new to avoid finding overloaded operator new Backport from mainline: 2016-08-06 Jonathan Wakely PR libstdc++/72820 * include/std/functional (_Function_base::_Base_manager::_M_clone): Qualify new operator. * testsuite/20_util/function/cons/72820.cc: New test. From-SVN: r241264 --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 895192159816..77d7de5a136d 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,13 @@ +2016-10-17 Jonathan Wakely + + Backport from mainline: + 2016-08-06 Jonathan Wakely + + PR libstdc++/72820 + * include/std/functional (_Function_base::_Base_manager::_M_clone): + Qualify new operator. + * testsuite/20_util/function/cons/72820.cc: New test. + 2016-10-17 Jonathan Wakely PR libstdc++/77994 diff --git a/libstdc++-v3/include/std/functional b/libstdc++-v3/include/std/functional index 9b0f801da1c9..e3fce0cada93 100644 --- a/libstdc++-v3/include/std/functional +++ b/libstdc++-v3/include/std/functional @@ -1699,7 +1699,7 @@ _GLIBCXX_MEM_FN_TRAITS(&&, false_type, true_type) static void _M_clone(_Any_data& __dest, const _Any_data& __source, true_type) { - new (__dest._M_access()) _Functor(__source._M_access<_Functor>()); + ::new (__dest._M_access()) _Functor(__source._M_access<_Functor>()); } // Clone a function object that is not location-invariant or @@ -1780,7 +1780,7 @@ _GLIBCXX_MEM_FN_TRAITS(&&, false_type, true_type) private: static void _M_init_functor(_Any_data& __functor, _Functor&& __f, true_type) - { new (__functor._M_access()) _Functor(std::move(__f)); } + { ::new (__functor._M_access()) _Functor(std::move(__f)); } static void _M_init_functor(_Any_data& __functor, _Functor&& __f, false_type) diff --git a/libstdc++-v3/testsuite/20_util/function/cons/72820.cc b/libstdc++-v3/testsuite/20_util/function/cons/72820.cc new file mode 100644 index 000000000000..1e4e0e8aabfe --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/function/cons/72820.cc @@ -0,0 +1,28 @@ +// Copyright (C) 2016 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-options "-std=gnu++11" } +// { dg-do compile } + +#include + +struct foo { + void operator()() { } + static void* operator new(std::size_t, void* p); +}; + +std::function f = foo{};