From mboxrd@z Thu Jan 1 00:00:00 1970
Return-Path:
Received: by sourceware.org (Postfix, from userid 2181)
id 821683858C27; Thu, 9 Dec 2021 23:24:13 +0000 (GMT)
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 821683858C27
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain; charset="utf-8"
From: Jonathan Wakely
To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org
Subject: [gcc r12-5873] libstdc++: Fix non-reserved name in std::allocator
base class [PR64135]
X-Act-Checkin: gcc
X-Git-Author: Jonathan Wakely
X-Git-Refname: refs/heads/master
X-Git-Oldrev: f157c5362b4844f7676cae2aba81a4cf75bd68d5
X-Git-Newrev: fe9571a35db53e5203326f854f73e432691d67f6
Message-Id: <20211209232413.821683858C27@sourceware.org>
Date: Thu, 9 Dec 2021 23:24:13 +0000 (GMT)
X-BeenThere: gcc-cvs@gcc.gnu.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Gcc-cvs mailing list
List-Unsubscribe: ,
List-Archive:
List-Help:
List-Subscribe: ,
X-List-Received-Date: Thu, 09 Dec 2021 23:24:13 -0000
https://gcc.gnu.org/g:fe9571a35db53e5203326f854f73e432691d67f6
commit r12-5873-gfe9571a35db53e5203326f854f73e432691d67f6
Author: Jonathan Wakely
Date: Wed Dec 1 17:56:23 2021 +0000
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
instead of .
(__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.
Diff:
---
libstdc++-v3/config/allocator/new_allocator_base.h | 11 +-
libstdc++-v3/doc/html/manual/api.html | 3 +
libstdc++-v3/doc/html/manual/memory.html | 6 +-
libstdc++-v3/doc/xml/manual/allocator.xml | 6 +-
libstdc++-v3/doc/xml/manual/evolution.xml | 3 +
libstdc++-v3/include/Makefile.am | 1 +
libstdc++-v3/include/Makefile.in | 1 +
libstdc++-v3/include/bits/new_allocator.h | 223 +++++++++++++++++++++
libstdc++-v3/include/experimental/memory_resource | 4 +-
libstdc++-v3/include/ext/new_allocator.h | 157 +--------------
libstdc++-v3/testsuite/20_util/allocator/64135.cc | 45 +++++
11 files changed, 293 insertions(+), 167 deletions(-)
diff --git a/libstdc++-v3/config/allocator/new_allocator_base.h b/libstdc++-v3/config/allocator/new_allocator_base.h
index 7c52fef63de..a139f2fb668 100644
--- a/libstdc++-v3/config/allocator/new_allocator_base.h
+++ b/libstdc++-v3/config/allocator/new_allocator_base.h
@@ -30,7 +30,7 @@
#ifndef _GLIBCXX_CXX_ALLOCATOR_H
#define _GLIBCXX_CXX_ALLOCATOR_H 1
-#include
+#include
#if __cplusplus >= 201103L
namespace std
@@ -38,18 +38,17 @@ namespace std
/**
* @brief An alias to the base class for std::allocator.
*
- * Used to set the std::allocator base class to
- * __gnu_cxx::new_allocator.
+ * Used to set the std::allocator base class to std::__new_allocator.
*
* @ingroup allocators
* @tparam _Tp Type of allocated object.
*/
template
- using __allocator_base = __gnu_cxx::new_allocator<_Tp>;
+ using __allocator_base = __new_allocator<_Tp>;
}
#else
-// Define new_allocator as the base class to std::allocator.
-# define __allocator_base __gnu_cxx::new_allocator
+// Define __new_allocator as the base class to std::allocator.
+# define __allocator_base __new_allocator
#endif
#ifndef _GLIBCXX_SANITIZE_STD_ALLOCATOR
diff --git a/libstdc++-v3/doc/html/manual/api.html b/libstdc++-v3/doc/html/manual/api.html
index 2cc44aed4e3..00701fa1044 100644
--- a/libstdc++-v3/doc/html/manual/api.html
+++ b/libstdc++-v3/doc/html/manual/api.html
@@ -447,4 +447,7 @@ Dynamic exception specifications should be replaced with noex
The bitmap
, mt
, and pool
options for --enable-libstdcxx-allocator
were removed.
+For the new
option, std::allocator
+no longer derives from __gnu_cxx::new_allocator
;
+they both derive from std::__new_allocator
instead.