https://gcc.gnu.org/g:671b96fcf584ba2934a37b353ace315f65ed93a4

commit r13-10322-g671b96fcf584ba2934a37b353ace315f65ed93a4
Author: Jonathan Wakely <[email protected]>
Date:   Mon Mar 18 13:09:52 2024 +0000

    libstdc++: Use feature test macros in <bits/stl_construct.h>
    
    The preprocessor checks for __cplusplus in <bits/stl_construct.h> should
    use the appropriate feature test macros instead of __cplusplus, namely
    __cpp_constexpr_dynamic_alloc.
    
    We want to check the compiler macro not the library's
    __cpp_lib_constexpr_dynamic_alloc, because the latter is not defined for
    freestanding but std::construct_at needs to be.
    
    This gcc-13 backport doesn't include the changes to check the
    __glibcxx_raw_memory_algorithms macro instead of __cplusplus >= 201703L
    because the __glibcxx_foo forms of macros were not added until gcc-14,
    and the __cpp_lib_raw_memory_algorithms macro is only defined by
    bits/stl_uninitialized.h, which isn't included here.
    
    libstdc++-v3/ChangeLog:
    
            * include/bits/stl_construct.h (construct_at): Guard
            with feature test macros instead of just __cplusplus.
    
    (cherry picked from commit 8539c5610a7c36099af2ea756d8bbfa398a40e0b)

Diff:
---
 libstdc++-v3/include/bits/stl_construct.h | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/libstdc++-v3/include/bits/stl_construct.h 
b/libstdc++-v3/include/bits/stl_construct.h
index cf62d927cdb7..3403c3a4aeed 100644
--- a/libstdc++-v3/include/bits/stl_construct.h
+++ b/libstdc++-v3/include/bits/stl_construct.h
@@ -88,7 +88,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        __location->~_Tp();
     }
 
-#if __cplusplus >= 202002L
+#if __cpp_constexpr_dynamic_alloc // >= C++20
   template<typename _Tp, typename... _Args>
     constexpr auto
     construct_at(_Tp* __location, _Args&&... __args)
@@ -108,7 +108,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     inline void
     _Construct(_Tp* __p, _Args&&... __args)
     {
-#if __cplusplus >= 202002L
+#if __cpp_constexpr_dynamic_alloc // >= C++20
       if (std::__is_constant_evaluated())
        {
          // Allow std::_Construct to be used in constant expressions.
@@ -145,7 +145,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     _GLIBCXX14_CONSTEXPR inline void
     _Destroy(_Tp* __pointer)
     {
-#if __cplusplus > 201703L
+#if __cpp_constexpr_dynamic_alloc // >= C++20
       std::destroy_at(__pointer);
 #else
       __pointer->~_Tp();
@@ -188,7 +188,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       static_assert(is_destructible<_Value_type>::value,
                    "value type is destructible");
 #endif
-#if __cplusplus >= 202002L
+#if __cpp_constexpr_dynamic_alloc // >= C++20
       if (std::__is_constant_evaluated())
        return std::_Destroy_aux<false>::__destroy(__first, __last);
 #endif
@@ -237,7 +237,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       static_assert(is_destructible<_Value_type>::value,
                    "value type is destructible");
 #endif
-#if __cplusplus >= 202002L
+#if __cpp_constexpr_dynamic_alloc // >= C++20
       if (std::__is_constant_evaluated())
        return std::_Destroy_n_aux<false>::__destroy_n(__first, __count);
 #endif

Reply via email to