* [PATCH] Use ::new to avoid finding overloaded operator new
@ 2016-08-06 10:20 Jonathan Wakely
0 siblings, 0 replies; only message in thread
From: Jonathan Wakely @ 2016-08-06 10:20 UTC (permalink / raw)
To: libstdc++, gcc-patches
[-- Attachment #1: Type: text/plain, Size: 444 bytes --]
As I mentioned in the variant patch thread yesterday, we're not
qualifying the new operator correctly in std::function, so the test
case in this patch was failing.
PR libstdc++/72820
* include/std/functional (_Function_base::_Base_manager::_M_clone):
Qualify new operator.
* testsuite/20_util/function/cons/72820.cc: New test.
Tested powerpc64-linux, committed to trunk. I'll probably backport it
to the branches after 6.2 is released.
[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 2554 bytes --]
commit 1ecfcb02f41ac6cacdd7284eee6d310040f64ecf
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Fri Aug 5 17:15:06 2016 +0100
Use ::new to avoid finding overloaded operator new
PR libstdc++/72820
* include/std/functional (_Function_base::_Base_manager::_M_clone):
Qualify new operator.
* testsuite/20_util/function/cons/72820.cc: New test.
diff --git a/libstdc++-v3/include/std/functional b/libstdc++-v3/include/std/functional
index 1de914e..8608134 100644
--- a/libstdc++-v3/include/std/functional
+++ b/libstdc++-v3/include/std/functional
@@ -1472,7 +1472,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
@@ -1553,7 +1553,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 0000000..1b17aae
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/function/cons/72820.cc
@@ -0,0 +1,27 @@
+// 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
+// <http://www.gnu.org/licenses/>.
+
+// { dg-do compile { target c++11 } }
+
+#include <functional>
+
+struct foo {
+ void operator()() { }
+ static void* operator new(std::size_t, void* p);
+};
+
+std::function<void()> f = foo{};
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2016-08-06 10:20 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-06 10:20 [PATCH] Use ::new to avoid finding overloaded operator new Jonathan Wakely
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).