From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2181) id 527003858C32; Fri, 22 Mar 2024 22:44:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 527003858C32 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1711147484; bh=6+rAGUdVXVQyqzOU4lfNGdes1Lp+YeeVguaUOTuvGc8=; h=From:To:Subject:Date:From; b=lZ9YM+Nei+Aa7P2axDIOVZLW95KYrPC4VtMh8KOiR98u8lrnxPh4tq/u88Um6AeFE i2Wa/EMFs0jLSGQPNim3RnS4jG9uv8kopOH3wK0WQG9VrsyEJknugvWOzJoY2ObY0o 1qg5DNB5TfuyLJnWtWQhY32XEWDnBwBgdYn+DAVo= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jonathan Wakely To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r14-9634] libstdc++: Use feature test macros in X-Act-Checkin: gcc X-Git-Author: Jonathan Wakely X-Git-Refname: refs/heads/master X-Git-Oldrev: ff773ac3d9c2bec21fa1a56cad99d63a1cf2a74f X-Git-Newrev: 8539c5610a7c36099af2ea756d8bbfa398a40e0b Message-Id: <20240322224444.527003858C32@sourceware.org> Date: Fri, 22 Mar 2024 22:44:44 +0000 (GMT) List-Id: https://gcc.gnu.org/g:8539c5610a7c36099af2ea756d8bbfa398a40e0b commit r14-9634-g8539c5610a7c36099af2ea756d8bbfa398a40e0b Author: Jonathan Wakely Date: Mon Mar 18 13:09:52 2024 +0000 libstdc++: Use feature test macros in The preprocessor checks for __cplusplus in should use the appropriate feature test macros instead of __cplusplus, namely __glibcxx_raw_memory_algorithms and __cpp_constexpr_dynamic_alloc. For the latter, 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. libstdc++-v3/ChangeLog: * include/bits/stl_construct.h (destroy_at, construct_at): Guard with feature test macros instead of just __cplusplus. Diff: --- libstdc++-v3/include/bits/stl_construct.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/libstdc++-v3/include/bits/stl_construct.h b/libstdc++-v3/include/bits/stl_construct.h index 7c394072b50..dc08fb7ea33 100644 --- a/libstdc++-v3/include/bits/stl_construct.h +++ b/libstdc++-v3/include/bits/stl_construct.h @@ -74,7 +74,7 @@ namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION -#if __cplusplus >= 201703L +#if __glibcxx_raw_memory_algorithms // >= C++17 template _GLIBCXX20_CONSTEXPR inline void destroy_at(_Tp* __location) @@ -88,7 +88,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __location->~_Tp(); } -#if __cplusplus >= 202002L +#if __cpp_constexpr_dynamic_alloc // >= C++20 template 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::__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::__destroy_n(__first, __count); #endif @@ -245,7 +245,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __destroy_n(__first, __count); } -#if __cplusplus >= 201703L +#if __glibcxx_raw_memory_algorithms // >= C++17 template _GLIBCXX20_CONSTEXPR inline void destroy(_ForwardIterator __first, _ForwardIterator __last)