From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id E6C703858430 for ; Tue, 19 Mar 2024 15:57:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E6C703858430 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org E6C703858430 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1710863836; cv=none; b=aeLoKWkb+NBOTI22vbHxwHwdt+4Q7ODDtHlQVx9CfBl0OePp/a6pdKNNqUjEgUTQWKv42uby/bYlMtOzW5G7JVTHTY/9J7ujo8x170ElHHPgpb1637Av+qXZJ4Q51VkYloHqcRnppuNgsBS44b+MOkRhtkGH/LylXYSOLpSHCtk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1710863836; c=relaxed/simple; bh=w1aJ9YBhJmiDy+9aDycsij2nrC3GHtNzANFz2malRvc=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=ElLyNO8xBSEIgkpkQv/bqwMUGpHLOO8dQm2drppfralYyygR+GbkryYre+w1d3kDHEDUg4QJNDrNlmKgmAcikGg18lcZ0wTWAcJVHGO29oz7bZAWCfkGByQiTnsG/pIKmZaORLFYMV/Z5D0GU03gRCNE+XZmWUJf1t3K/1G46Qs= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710863834; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=mEtXV0VMZtpNMUzGtOpHXg3CirWYDdUOwvQXBCYSyJM=; b=Yt2xNL3jZuKq/E3f0u/LqnTE4VIBCVUBki/RJXLlOXzSjTAb+if/idjWxkUMsJz9BH71tF 08XsiQeIunsh5d4wBa1TiF4Vtf81K1IDLs8HZe9HM/jCdfInB6cXfVHHdpCvhkO3V0sdmn mk2RAHGs9XXETP2vdLnGFUv0/t3M3bM= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-110-euCUMo1TNN-KXrQ7TADWzg-1; Tue, 19 Mar 2024 11:57:10 -0400 X-MC-Unique: euCUMo1TNN-KXrQ7TADWzg-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4F3E328C97CD; Tue, 19 Mar 2024 15:57:10 +0000 (UTC) Received: from localhost (unknown [10.42.28.8]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0D5923C20; Tue, 19 Mar 2024 15:57:09 +0000 (UTC) From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [PATCH] libstdc++: Use feature test macros in Date: Tue, 19 Mar 2024 15:52:01 +0000 Message-ID: <20240319155649.3399665-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Does anybody see any issues with making this change? The __cpp_constexpr_dynamic_alloc macro is defined with -std=c++2a since Clang 10.0.0 so this won't result in std::construct_at disappearing by anybody using libstdc++ with Clang. Tested x86_64-linux and aarch64-linux. Basic smoke tests checked with Clang 16 too. -- >8 -- 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. --- 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) -- 2.44.0