From 6feae66da1d652a50c1759bae46128087f7dfab0 Mon Sep 17 00:00:00 2001 From: Tom de Vries Date: Thu, 17 Aug 2023 10:41:34 +0200 Subject: [PATCH] [gdb/build, c++20] Handle deprecated std::allocator::construct MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit When building gdb with -std=c++20, I run into: ... gdbsupport/default-init-alloc.h:52:12: error: ‘construct’ has not been \ declared in ‘class std::allocator’ 52 | using A::construct; | ^~~~~~~~~ ... Indeed, std::allocator::construct has been deprecated in c++17 and removed in c++20. Fix this by using instead std::pmr::polymorphic_allocator for c++20. Tested on x86_64-linux. --- gdbsupport/default-init-alloc.h | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/gdbsupport/default-init-alloc.h b/gdbsupport/default-init-alloc.h index 9c8b5a2c689..e2d3bd24516 100644 --- a/gdbsupport/default-init-alloc.h +++ b/gdbsupport/default-init-alloc.h @@ -18,6 +18,10 @@ #ifndef COMMON_DEFAULT_INIT_ALLOC_H #define COMMON_DEFAULT_INIT_ALLOC_H +#if __cplusplus >= 202002L +#include +#endif + namespace gdb { /* An allocator that default constructs using default-initialization @@ -29,7 +33,14 @@ namespace gdb { adapter that given an allocator A, overrides 'A::construct()'. 'A' defaults to std::allocator. */ -template> +template= 202002L + = std::pmr::polymorphic_allocator +#else + = std::allocator +#endif + > class default_init_allocator : public A { public: -- 2.30.2