From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 40252 invoked by alias); 29 Oct 2019 20:16:59 -0000 Mailing-List: contact libstdc++-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libstdc++-owner@gcc.gnu.org Received: (qmail 40050 invoked by uid 89); 29 Oct 2019 20:16:58 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-16.9 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_PASS autolearn=unavailable version=3.3.1 spammy= X-HELO: us-smtp-delivery-1.mimecast.com Received: from us-smtp-2.mimecast.com (HELO us-smtp-delivery-1.mimecast.com) (207.211.31.81) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 29 Oct 2019 20:16:57 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1572380215; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=WdrHz6pGt4D+wHSkN10W5J0Gcs2dShZUXEgdV/nD3F4=; b=eXFVY+X9Mi91cZ+TTW5/lMYiEx/ZhMskzbPK8yQFEDZKQ4fX9IgfiauerNhqn+HlnU62Gq wJ29Sqyat6n3jm10HoPvs628JT+sFg20ZFuqC9BJ7jW0eftoA694sZbWxgiI/Azwx2n+BF zr1hu/XE45j0/vQ7ByocjJhKFfdfOpM= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-345-_DFQA5i6MQ2nTmQQQ2nbqw-1; Tue, 29 Oct 2019 16:16:51 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1600F180496F; Tue, 29 Oct 2019 20:16:51 +0000 (UTC) Received: from localhost (unknown [10.33.36.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id B640B5D6D0; Tue, 29 Oct 2019 20:16:50 +0000 (UTC) Date: Tue, 29 Oct 2019 20:16:00 -0000 From: Jonathan Wakely To: Stephan Bergmann Cc: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: Re: [PATCH] PR c++/91369 Implement P0784R7 changes to allocation and construction Message-ID: <20191029201650.GE4169@redhat.com> References: <20191023192708.GA981@redhat.com> <20191029093719.GD4169@redhat.com> MIME-Version: 1.0 In-Reply-To: <20191029093719.GD4169@redhat.com> X-Clacks-Overhead: GNU Terry Pratchett User-Agent: Mutt/1.12.1 (2019-06-15) X-Mimecast-Spam-Score: 0 Content-Type: multipart/mixed; boundary="w2xx78T4DcG3O+DJ" Content-Disposition: inline X-IsSubscribed: yes X-SW-Source: 2019-10/txt/msg00127.txt.bz2 --w2xx78T4DcG3O+DJ Content-Type: text/plain; charset=WINDOWS-1252; format=flowed Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-length: 1581 On 29/10/19 09:37 +0000, Jonathan Wakely wrote: >On 29/10/19 10:23 +0100, Stephan Bergmann wrote: >>On 23/10/2019 21:27, Jonathan Wakely wrote: >>>This patch is the first part of library support for constexpr >>>std::vector and std::string. This only includes the changes to >>>std::allocator, std::allocator_traits, std::construct_at, >>>std::destroy_at, std::destroy and std::destroy_n. >>[...] >>>Tested x86_64-linux and powerpc64le-linux, for every -std=3Dgnu++NN >>>mode. >> >>Clang (trunk, at least) with -std=3Dc++11 now complains about some of=20 >>the constexpr (because they return void, or don't have a return=20 >>statement) when including . > >Ah, thanks for letting me know. I did test with Clang, but not with >-std=3Dc++11. I'll add that to my set of checks. > >>What fixed it for me locally: >> >>>diff --git a/libstdc++-v3/include/bits/alloc_traits.h b/libstdc++-v3/inc= lude/bits/alloc_traits.h >>>index 26d6d26ae48..61d3c1b794b 100644 >>>--- a/libstdc++-v3/include/bits/alloc_traits.h >>>+++ b/libstdc++-v3/include/bits/alloc_traits.h >>>@@ -241,13 +241,20 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION >>> =3D typename __construct_helper<_Tp, _Args...>::type; >>> template >>>- static constexpr _Require<__has_construct<_Tp, _Args...>> >>>+ static >>>+#if __cplusplus >=3D 201402L >>>+ constexpr >>>+#endif > >That's what the _GLIBCXX14_CONSTEXPR macro is for. > >I'll fix this today, thanks. Fixed with this, tested on powerpc64le-linux, and smoke tested on x86_64-linux using Clang 7.0.1. Committed to trunk. --w2xx78T4DcG3O+DJ Content-Type: text/x-patch; charset=WINDOWS-1252 Content-Disposition: attachment; filename="patch.txt" Content-Transfer-Encoding: quoted-printable Content-length: 5470 commit 94674310b112c55010cfe4f49f0236fecb2dccb8 Author: Jonathan Wakely Date: Tue Oct 29 19:33:51 2019 +0000 Fix compilation errors with Clang =20=20=20=20 * include/bits/alloc_traits.h (__cpp_lib_constexpr_dynamic_allo= c): Define. (allocator_traits::_S_construct, allocator_traits::_S_destroy) (__alloc_on_copy, __alloc_on_move, __alloc_on_swap): Use _GLIBCXX14_CONSTEXPR instead of constexpr. * include/bits/stl_construct.h (_Destroy): Likewise. diff --git a/libstdc++-v3/include/bits/alloc_traits.h b/libstdc++-v3/includ= e/bits/alloc_traits.h index 26d6d26ae48..55211ac1d72 100644 --- a/libstdc++-v3/include/bits/alloc_traits.h +++ b/libstdc++-v3/include/bits/alloc_traits.h @@ -241,13 +241,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION =3D typename __construct_helper<_Tp, _Args...>::type; =20 template - static constexpr _Require<__has_construct<_Tp, _Args...>> + static _GLIBCXX14_CONSTEXPR _Require<__has_construct<_Tp, _Args...>> _S_construct(_Alloc& __a, _Tp* __p, _Args&&... __args) noexcept(noexcept(__a.construct(__p, std::forward<_Args>(__args)...))) { __a.construct(__p, std::forward<_Args>(__args)...); } =20 template - static constexpr + static _GLIBCXX14_CONSTEXPR _Require<__and_<__not_<__has_construct<_Tp, _Args...>>, is_constructible<_Tp, _Args...>>> _S_construct(_Alloc&, _Tp* __p, _Args&&... __args) @@ -256,14 +256,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { std::_Construct(__p, std::forward<_Args>(__args)...); } =20 template - static constexpr auto + static _GLIBCXX14_CONSTEXPR auto _S_destroy(_Alloc2& __a, _Tp* __p, int) noexcept(noexcept(__a.destroy(__p))) -> decltype(__a.destroy(__p)) { __a.destroy(__p); } =20 template - static constexpr void + static _GLIBCXX14_CONSTEXPR void _S_destroy(_Alloc2&, _Tp* __p, ...) noexcept(noexcept(__p->~_Tp())) { std::_Destroy(__p); } @@ -393,6 +393,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return _S_select(__rhs, 0); } }; =20 +#if __cplusplus > 201703L +# define __cpp_lib_constexpr_dynamic_alloc 201907L +#endif + /// Partial specialization for std::allocator. template struct allocator_traits> @@ -562,7 +566,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #endif =20 template - constexpr void + _GLIBCXX14_CONSTEXPR void __alloc_on_copy(_Alloc& __one, const _Alloc& __two) { typedef allocator_traits<_Alloc> __traits; @@ -594,7 +598,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #endif =20 template - constexpr void + _GLIBCXX14_CONSTEXPR void __alloc_on_move(_Alloc& __one, _Alloc& __two) { typedef allocator_traits<_Alloc> __traits; @@ -621,7 +625,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #endif =20 template - constexpr void + _GLIBCXX14_CONSTEXPR void __alloc_on_swap(_Alloc& __one, _Alloc& __two) { typedef allocator_traits<_Alloc> __traits; diff --git a/libstdc++-v3/include/bits/stl_construct.h b/libstdc++-v3/inclu= de/bits/stl_construct.h index a16196ffe74..c714148e037 100644 --- a/libstdc++-v3/include/bits/stl_construct.h +++ b/libstdc++-v3/include/bits/stl_construct.h @@ -137,7 +137,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * Destroy the object pointed to by a pointer type. */ template - _GLIBCXX_CONSTEXPR inline void + _GLIBCXX14_CONSTEXPR inline void _Destroy(_Tp* __pointer) { #if __cplusplus > 201703L diff --git a/libstdc++-v3/include/ext/alloc_traits.h b/libstdc++-v3/include= /ext/alloc_traits.h index 052d811ec01..c7b8e5d4ba3 100644 --- a/libstdc++-v3/include/ext/alloc_traits.h +++ b/libstdc++-v3/include/ext/alloc_traits.h @@ -76,7 +76,8 @@ template public: // overload construct for non-standard pointer types template - static constexpr std::__enable_if_t<__is_custom_pointer<_Ptr>::value> + static _GLIBCXX14_CONSTEXPR + std::__enable_if_t<__is_custom_pointer<_Ptr>::value> construct(_Alloc& __a, _Ptr __p, _Args&&... __args) noexcept(noexcept(_Base_type::construct(__a, std::__to_address(__p), std::forward<_Args>(__args)...))) @@ -87,7 +88,8 @@ template =20 // overload destroy for non-standard pointer types template - static constexpr std::__enable_if_t<__is_custom_pointer<_Ptr>::value> + static _GLIBCXX14_CONSTEXPR + std::__enable_if_t<__is_custom_pointer<_Ptr>::value> destroy(_Alloc& __a, _Ptr __p) noexcept(noexcept(_Base_type::destroy(__a, std::__to_address(__p)))) { _Base_type::destroy(__a, std::__to_address(__p)); } @@ -95,7 +97,7 @@ template static constexpr _Alloc _S_select_on_copy(const _Alloc& __a) { return _Base_type::select_on_container_copy_construction(__a); } =20 - static constexpr void _S_on_swap(_Alloc& __a, _Alloc& __b) + static _GLIBCXX14_CONSTEXPR void _S_on_swap(_Alloc& __a, _Alloc& __b) { std::__alloc_on_swap(__a, __b); } =20 static constexpr bool _S_propagate_on_copy_assign() --w2xx78T4DcG3O+DJ--