From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1059) id DC7D2386180E; Fri, 28 Aug 2020 16:03:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DC7D2386180E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1598630605; bh=6C8sQs0OInUrHnZx1hXGEZkUcaw0mCjfWFBGpp7hZ4E=; h=From:To:Subject:Date:From; b=PkPhphjFhBXhvOG40Ljhb31VmO0FeHmqMOCz6S282TcLy0EjxyOU7NJFgSIvk7VXU xH+j6aegbmnBCCnBmBOt7+k7j4r5B6vSlJSJ41GmXOcTsOy7Bf9LDFUru8thSHxYFX ZZSTY5p2vKIc/FiD2EyuKVmvFwM0pxjyDBTEb60A= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Nathan Sidwell To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc/devel/c++-modules] libstdc++: Adjust static assertions in futures and promises [LWG 3466] X-Act-Checkin: gcc X-Git-Author: Jonathan Wakely X-Git-Refname: refs/heads/devel/c++-modules X-Git-Oldrev: 03d5044b31f7bf94fcda4136b4ed87a5fee7735d X-Git-Newrev: 71ed3c0c9a3458998bded8e2443c0a680c2eb8cd Message-Id: <20200828160325.DC7D2386180E@sourceware.org> Date: Fri, 28 Aug 2020 16:03:25 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 28 Aug 2020 16:03:26 -0000 https://gcc.gnu.org/g:71ed3c0c9a3458998bded8e2443c0a680c2eb8cd commit 71ed3c0c9a3458998bded8e2443c0a680c2eb8cd Author: Jonathan Wakely Date: Tue Aug 25 15:52:57 2020 +0100 libstdc++: Adjust static assertions in futures and promises [LWG 3466] Add a static_assertions to check the result type is destructible, as in the proposed resolution for LWG 3466 (which supersedes 3458). libstdc++-v3/ChangeLog: * include/std/future (future, shared_future. promise): Add is_destructible assertion (LWG 3466). Adjust string-literal for !is_array and !is_function assertions. * testsuite/30_threads/future/requirements/lwg3458.cc: Check types with no accessible destructor. Adjust expected errors. * testsuite/30_threads/promise/requirements/lwg3466.cc: Likewise. * testsuite/30_threads/shared_future/requirements/lwg3458.cc: Likewise. Diff: --- libstdc++-v3/include/std/future | 18 ++++++++++++------ .../30_threads/future/requirements/lwg3458.cc | 13 +++++++++++-- .../30_threads/promise/requirements/lwg3466.cc | 13 +++++++++++-- .../30_threads/shared_future/requirements/lwg3458.cc | 13 +++++++++++-- 4 files changed, 45 insertions(+), 12 deletions(-) diff --git a/libstdc++-v3/include/std/future b/libstdc++-v3/include/std/future index e0816c2f5e1..a7466a32e03 100644 --- a/libstdc++-v3/include/std/future +++ b/libstdc++-v3/include/std/future @@ -757,8 +757,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { // _GLIBCXX_RESOLVE_LIB_DEFECTS // 3458. Is shared_future intended to work with arrays or function types? - static_assert(!is_array<_Res>{}, "result type is not an array"); - static_assert(!is_function<_Res>{}, "result type is not a function"); + static_assert(!is_array<_Res>{}, "result type must not be an array"); + static_assert(!is_function<_Res>{}, "result type must not be a function"); + static_assert(is_destructible<_Res>{}, + "result type must be destructible"); friend class promise<_Res>; template friend class packaged_task; @@ -892,8 +894,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { // _GLIBCXX_RESOLVE_LIB_DEFECTS // 3458. Is shared_future intended to work with arrays or function types? - static_assert(!is_array<_Res>{}, "result type is not an array"); - static_assert(!is_function<_Res>{}, "result type is not a function"); + static_assert(!is_array<_Res>{}, "result type must not be an array"); + static_assert(!is_function<_Res>{}, "result type must not be a function"); + static_assert(is_destructible<_Res>{}, + "result type must be destructible"); typedef __basic_future<_Res> _Base_type; @@ -1049,8 +1053,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { // _GLIBCXX_RESOLVE_LIB_DEFECTS // 3466: Specify the requirements for promise/future/[...] consistently - static_assert(!is_array<_Res>{}, "result type is not an array"); - static_assert(!is_function<_Res>{}, "result type is not a function"); + static_assert(!is_array<_Res>{}, "result type must not be an array"); + static_assert(!is_function<_Res>{}, "result type must not be a function"); + static_assert(is_destructible<_Res>{}, + "result type must be destructible"); typedef __future_base::_State_base _State; typedef __future_base::_Result<_Res> _Res_type; diff --git a/libstdc++-v3/testsuite/30_threads/future/requirements/lwg3458.cc b/libstdc++-v3/testsuite/30_threads/future/requirements/lwg3458.cc index 2bc206c9450..f26e17bd799 100644 --- a/libstdc++-v3/testsuite/30_threads/future/requirements/lwg3458.cc +++ b/libstdc++-v3/testsuite/30_threads/future/requirements/lwg3458.cc @@ -26,9 +26,18 @@ std::future good; std::future good2; std::future bad; // { dg-error "here" } -// { dg-error "result type is not an array" "" { target *-*-* } 0 } +// { dg-error "result type must not be an array" "" { target *-*-* } 0 } // { dg-prune-output "function returning an array" } std::future bad2; // { dg-error "here" } -// { dg-error "result type is not a function" "" { target *-*-* } 0 } +// { dg-error "result type must not be a function" "" { target *-*-* } 0 } // { dg-prune-output "function returning a function" } + +struct Indestructible { ~Indestructible() = delete; }; +std::future bad3; // { dg-error "here" } +// { dg-error "result type must be destructible" "" { target *-*-* } 0 } +// { dg-prune-output {deleted function} } + +class PrivateDtor { public: PrivateDtor(); private: ~PrivateDtor(); }; +std::future bad4; // { dg-error "here" } +// { dg-prune-output {is private} } diff --git a/libstdc++-v3/testsuite/30_threads/promise/requirements/lwg3466.cc b/libstdc++-v3/testsuite/30_threads/promise/requirements/lwg3466.cc index 124c86c0392..71eb2603e83 100644 --- a/libstdc++-v3/testsuite/30_threads/promise/requirements/lwg3466.cc +++ b/libstdc++-v3/testsuite/30_threads/promise/requirements/lwg3466.cc @@ -26,9 +26,18 @@ std::promise good; std::promise good2; std::promise bad; // { dg-error "here" } -// { dg-error "result type is not an array" "" { target *-*-* } 0 } +// { dg-error "result type must not be an array" "" { target *-*-* } 0 } // { dg-prune-output {request for member '~int \[1\]'} } std::promise bad2; // { dg-error "here" } -// { dg-error "result type is not a function" "" { target *-*-* } 0 } +// { dg-error "result type must not be a function" "" { target *-*-* } 0 } // { dg-prune-output {'sizeof \(int\(\)\)'} } + +struct Indestructible { ~Indestructible() = delete; }; +std::promise bad3; // { dg-error "here" } +// { dg-error "result type must be destructible" "" { target *-*-* } 0 } +// { dg-prune-output {deleted function} } + +class PrivateDtor { public: PrivateDtor(); private: ~PrivateDtor(); }; +std::promise bad4; // { dg-error "here" } +// { dg-prune-output {is private} } diff --git a/libstdc++-v3/testsuite/30_threads/shared_future/requirements/lwg3458.cc b/libstdc++-v3/testsuite/30_threads/shared_future/requirements/lwg3458.cc index df5bfd2b976..cf767698f40 100644 --- a/libstdc++-v3/testsuite/30_threads/shared_future/requirements/lwg3458.cc +++ b/libstdc++-v3/testsuite/30_threads/shared_future/requirements/lwg3458.cc @@ -26,7 +26,16 @@ std::shared_future good; std::shared_future good2; std::shared_future bad; // { dg-error "here" } -// { dg-error "result type is not an array" "" { target *-*-* } 0 } +// { dg-error "result type must not be an array" "" { target *-*-* } 0 } std::shared_future bad2; // { dg-error "here" } -// { dg-error "result type is not a function" "" { target *-*-* } 0 } +// { dg-error "result type must not be a function" "" { target *-*-* } 0 } + +struct Indestructible { ~Indestructible() = delete; }; +std::shared_future bad3; // { dg-error "here" } +// { dg-error "result type must be destructible" "" { target *-*-* } 0 } +// { dg-prune-output {deleted function} } + +class PrivateDtor { public: PrivateDtor(); private: ~PrivateDtor(); }; +std::shared_future bad4; // { dg-error "here" } +// { dg-prune-output {is private} }