version.syn#2 requires <string> to define __cpp_lib_allocator_traits_is_always_equal.
The attached patch therefore defines the __glibcxx_want_allocator_traits_is_always_equal macro to get the definition of the feature-test macro from <bits/version.h>. This is not isolated only to <string> though. The standard requires the following (as per version.syn#2): #define __cpp_lib_allocator_traits_is_always_equal 201411L // freestanding, also in <memory>, <scoped_allocator>, <string>, <deque>, // <forward_list>, <list>, <vector>, <map>, <set>, <unordered_map>, // <unordered_set> After fixing <string>, all the above headers except <memory> still fail to define the macro. Should similar fixes be created for these headers as well? Signed-off-by: Dhruv Chawla <dhr...@nvidia.com> -- Regards, Dhruv
From 40c0b154f2ef11a18fd318008ae366560d4c8d79 Mon Sep 17 00:00:00 2001 From: Dhruv Chawla <dhr...@nvidia.com> Date: Mon, 26 Aug 2024 11:09:19 +0530 Subject: [PATCH] libstdc++: Add missing feature-test macro in <string> version.syn#2 requires <string> to define __cpp_lib_allocator_traits_is_always_equal. The attached patch therefore defines the __glibcxx_want_allocator_traits_is_always_equal macro to get the definition of the feature-test macro from <bits/version.h>. This is not isolated only to <string> though. The standard requires the following (as per version.syn#2): #define __cpp_lib_allocator_traits_is_always_equal 201411L // freestanding, also in <memory>, <scoped_allocator>, <string>, <deque>, // <forward_list>, <list>, <vector>, <map>, <set>, <unordered_map>, // <unordered_set> After fixing <string>, all the above headers except <memory> still fail to define the macro. Should similar fixes be created for these headers as well? Signed-off-by: Dhruv Chawla <dhr...@nvidia.com> libstdc++-v3/ChangeLog: * include/std/string: Define macro __glibcxx_want_allocator_traits_is_always_equal. --- libstdc++-v3/include/std/string | 1 + .../testsuite/21_strings/headers/string/version.cc | 8 ++++++++ 2 files changed, 9 insertions(+) create mode 100644 libstdc++-v3/testsuite/21_strings/headers/string/version.cc diff --git a/libstdc++-v3/include/std/string b/libstdc++-v3/include/std/string index 55144409cca..8db0802a282 100644 --- a/libstdc++-v3/include/std/string +++ b/libstdc++-v3/include/std/string @@ -54,6 +54,7 @@ #include <bits/basic_string.h> #include <bits/basic_string.tcc> +#define __glibcxx_want_allocator_traits_is_always_equal #define __glibcxx_want_constexpr_char_traits #define __glibcxx_want_constexpr_string #define __glibcxx_want_erase_if diff --git a/libstdc++-v3/testsuite/21_strings/headers/string/version.cc b/libstdc++-v3/testsuite/21_strings/headers/string/version.cc new file mode 100644 index 00000000000..a546b75b3fe --- /dev/null +++ b/libstdc++-v3/testsuite/21_strings/headers/string/version.cc @@ -0,0 +1,8 @@ +// { dg-do preprocess { target c++17 } } +// { dg-add-options no_pch } + +#include <string> + +#if __cpp_lib_allocator_traits_is_always_equal != 201411L +# error "Feature-test macro __cpp_lib_allocator_traits_is_always_equal has wrong value in <version>" +#endif -- 2.25.1