From: Tom de Vries Date: Thu, 17 Aug 2023 08:41:34 +0000 (+0200) Subject: [gdb/build, c++20] Handle deprecated std::allocator::construct X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=6feae66da1d652a50c1759bae46128087f7dfab0;p=binutils-gdb.git [gdb/build, c++20] Handle deprecated std::allocator::construct 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. --- 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: