summaryrefslogtreecommitdiff
path: root/libstdc++-v3/include/experimental
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2021-12-01 17:56:23 +0000
committerJonathan Wakely <jwakely@redhat.com>2021-12-09 22:50:10 +0000
commitfe9571a35db53e5203326f854f73e432691d67f6 (patch)
tree23acac00e45e11c3114e609d1578ff410d93bfaf /libstdc++-v3/include/experimental
parentf157c5362b4844f7676cae2aba81a4cf75bd68d5 (diff)
libstdc++: Fix non-reserved name in std::allocator base class [PR64135]
The possible base classes of std::allocator are new_allocator and malloc_allocator, which both cause a non-reserved name to be declared in every program that includes the definition of std::allocator. This is non-conforming. This change replaces __gnu_cxx::new_allocator with std::__new_allocator which is identical except for using a reserved name. The non-standard extension __gnu_cxx::new_allocator is preserved as a thin wrapper over std::__new_allocator. There is no problem with the extension using a non-reserved name now that it's not included by default in other headers. The same change could be done to __gnu_cxx::malloc_allocator but as it's not the default configuration it can wait. libstdc++-v3/ChangeLog: PR libstdc++/64135 * config/allocator/new_allocator_base.h: Include <bits/new_allocator.h> instead of <ext/new_allocator.h>. (__allocator_base): Use std::__new_allocator instead of __gnu_cxx::new_allocator. * doc/xml/manual/allocator.xml: Document new default base class for std::allocator. * doc/xml/manual/evolution.xml: Likewise. * doc/html/*: Regenerate. * include/Makefile.am: Add bits/new_allocator.h. * include/Makefile.in: Regenerate. * include/experimental/memory_resource (new_delete_resource): Use std::__new_allocator instead of __gnu_cxx::new_allocator. * include/ext/new_allocator.h (new_allocator): Derive from std::__new_allocator. Move implementation to ... * include/bits/new_allocator.h: New file. * testsuite/20_util/allocator/64135.cc: New test.
Diffstat (limited to 'libstdc++-v3/include/experimental')
-rw-r--r--libstdc++-v3/include/experimental/memory_resource4
1 files changed, 2 insertions, 2 deletions
diff --git a/libstdc++-v3/include/experimental/memory_resource b/libstdc++-v3/include/experimental/memory_resource
index 82d324c83b6..37ac95fc4b1 100644
--- a/libstdc++-v3/include/experimental/memory_resource
+++ b/libstdc++-v3/include/experimental/memory_resource
@@ -40,7 +40,7 @@
#include <atomic> // atomic
#include <new> // placement new
#include <cstddef> // max_align_t
-#include <ext/new_allocator.h>
+#include <bits/new_allocator.h>
#include <debug/assertions.h>
/// @cond
@@ -503,7 +503,7 @@ namespace pmr {
inline memory_resource*
new_delete_resource() noexcept
{
- using type = resource_adaptor<__gnu_cxx::new_allocator<char>>;
+ using type = resource_adaptor<std::__new_allocator<char>>;
alignas(type) static unsigned char __buf[sizeof(type)];
static type* __r = new(__buf) type;
return __r;