From patchwork Thu May 23 21:39:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 1104485 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-501578-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="uQVU8N1F"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4592vs0LkCz9sBb for ; Fri, 24 May 2019 07:39:36 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; q=dns; s= default; b=JIDOFbZmdlDrYKcytoW6XJqdvb2KvtqiaB/bdScU+7SWednIIYZ/B VZbXOA3+5qYFZA3EqkS56Abx9oSyAOYJ1xqeObJTGINuAdibyqjRZ9RwZuA7NU+J KCCowE3ti23d2pdyMTchWbRZQMVPF5dIPUZeivy5rDZkfFtfnBgkwI= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; s= default; bh=1V1qdNhadLxGalffbCiueumu/iw=; b=uQVU8N1FBMfghzeEn87a G7FaFlWyqvZ8FqglkS6PtzDUe7WasEc5zAGE2Sjxh6ceKcHRqAlo40gSHqDhvS9h 2wFZTTU0pvjV9GxC6KzvWizJ0MSyRN3IWTmsqRI/dYXfML1z4/m9C7PL1/ZYqQ96 OwRrk65HyO7DOj3vVRY3+y8= Received: (qmail 116361 invoked by alias); 23 May 2019 21:39:27 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 116343 invoked by uid 89); 23 May 2019 21:39:27 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-15.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, SPF_HELO_PASS autolearn=ham version=3.3.1 spammy=deferred X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 23 May 2019 21:39:23 +0000 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5696F30832EF; Thu, 23 May 2019 21:39:22 +0000 (UTC) Received: from localhost (unknown [10.33.36.15]) by smtp.corp.redhat.com (Postfix) with ESMTP id 08B1817197; Thu, 23 May 2019 21:39:21 +0000 (UTC) Date: Thu, 23 May 2019 22:39:21 +0100 From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [PATCH] LWG 2921 remove packaged_task constructors taking allocators Message-ID: <20190523213921.GA9072@redhat.com> MIME-Version: 1.0 Content-Disposition: inline X-Clacks-Overhead: GNU Terry Pratchett User-Agent: Mutt/1.11.3 (2019-02-01) * doc/xml/manual/evolution.xml: Document LWG DR 2921 change. * doc/xml/manual/intro.xml: Likewise. * include/std/future (__create_task_state): Add default arguments to make providing an allocator optional. (packaged_task::packaged_task(F&&)): Call __create_task_state directly instead of delegating to another constructor. (packaged_task::packaged_task(allocator_arg_t, const A&, ...)): Do not define allocator-extended constructors for C++17 and later. * testsuite/30_threads/packaged_task/cons/alloc.cc: Only run test for C++11 and C++14. * testsuite/30_threads/packaged_task/cons/alloc2.cc: Likewise. * testsuite/30_threads/packaged_task/cons/alloc_min.cc: Likewise. * testsuite/30_threads/packaged_task/uses_allocator.cc: Likewise. Tested powerpc64le-linux, committed to trunk. commit 6ee6d6fb851cb5f8ca80533fd37b8cbb882e6ad8 Author: Jonathan Wakely Date: Thu May 23 17:22:28 2019 +0100 LWG 2921 remove packaged_task constructors taking allocators * doc/xml/manual/evolution.xml: Document LWG DR 2921 change. * doc/xml/manual/intro.xml: Likewise. * include/std/future (__create_task_state): Add default arguments to make providing an allocator optional. (packaged_task::packaged_task(F&&)): Call __create_task_state directly instead of delegating to another constructor. (packaged_task::packaged_task(allocator_arg_t, const A&, ...)): Do not define allocator-extended constructors for C++17 and later. * testsuite/30_threads/packaged_task/cons/alloc.cc: Only run test for C++11 and C++14. * testsuite/30_threads/packaged_task/cons/alloc2.cc: Likewise. * testsuite/30_threads/packaged_task/cons/alloc_min.cc: Likewise. * testsuite/30_threads/packaged_task/uses_allocator.cc: Likewise. diff --git a/libstdc++-v3/doc/xml/manual/evolution.xml b/libstdc++-v3/doc/xml/manual/evolution.xml index 010907a2f6b..1bd7bb1bb9f 100644 --- a/libstdc++-v3/doc/xml/manual/evolution.xml +++ b/libstdc++-v3/doc/xml/manual/evolution.xml @@ -955,6 +955,11 @@ now defaults to zero. + + The std::packaged_task constructors taking + an allocator argument are only defined for C++11 and C++14. + + diff --git a/libstdc++-v3/doc/xml/manual/intro.xml b/libstdc++-v3/doc/xml/manual/intro.xml index 35a2016f5c3..a2162562b54 100644 --- a/libstdc++-v3/doc/xml/manual/intro.xml +++ b/libstdc++-v3/doc/xml/manual/intro.xml @@ -1221,6 +1221,14 @@ requirements of the license of GCC. Use rvalues for deleters. + 2921: + packaged_task and type-erased allocators + + + For C++17 mode, remove the constructors taking + an allocator argument. + + 2942: LWG 2873's resolution missed weak_ptr::owner_before diff --git a/libstdc++-v3/include/std/future b/libstdc++-v3/include/std/future index 967110050b8..6c276694df3 100644 --- a/libstdc++-v3/include/std/future +++ b/libstdc++-v3/include/std/future @@ -1447,9 +1447,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } _M_impl; }; - template + template> static shared_ptr<__future_base::_Task_state_base<_Signature>> - __create_task_state(_Fn&& __fn, const _Alloc& __a) + __create_task_state(_Fn&& __fn, const _Alloc& __a = _Alloc()) { typedef typename decay<_Fn>::type _Fn2; typedef __future_base::_Task_state<_Fn2, _Alloc, _Signature> _State; @@ -1481,27 +1482,39 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // Construction and destruction packaged_task() noexcept { } + template> + explicit + packaged_task(_Fn&& __fn) + : _M_state( + __create_task_state<_Res(_ArgTypes...)>(std::forward<_Fn>(__fn))) + { } + +#if __cplusplus < 201703L + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2097. packaged_task constructors should be constrained + // 2407. [this constructor should not be] explicit + // 2921. packaged_task and type-erased allocators + template> + packaged_task(allocator_arg_t, const _Alloc& __a, _Fn&& __fn) + : _M_state(__create_task_state<_Res(_ArgTypes...)>( + std::forward<_Fn>(__fn), __a)) + { } + // _GLIBCXX_RESOLVE_LIB_DEFECTS // 2095. missing constructors needed for uses-allocator construction template packaged_task(allocator_arg_t, const _Allocator& __a) noexcept { } - template> - explicit - packaged_task(_Fn&& __fn) - : packaged_task(allocator_arg, std::allocator(), - std::forward<_Fn>(__fn)) - { } + template + packaged_task(allocator_arg_t, const _Allocator&, + const packaged_task&) = delete; - // _GLIBCXX_RESOLVE_LIB_DEFECTS - // 2097. packaged_task constructors should be constrained - // 2407. [this constructor should not be] explicit - template> - packaged_task(allocator_arg_t, const _Alloc& __a, _Fn&& __fn) - : _M_state(__create_task_state<_Res(_ArgTypes...)>( - std::forward<_Fn>(__fn), __a)) - { } + template + packaged_task(allocator_arg_t, const _Allocator&, + packaged_task&& __other) noexcept + { this->swap(__other); } +#endif ~packaged_task() { @@ -1513,19 +1526,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION packaged_task(const packaged_task&) = delete; packaged_task& operator=(const packaged_task&) = delete; - template - packaged_task(allocator_arg_t, const _Allocator&, - const packaged_task&) = delete; - // Move support packaged_task(packaged_task&& __other) noexcept { this->swap(__other); } - template - packaged_task(allocator_arg_t, const _Allocator&, - packaged_task&& __other) noexcept - { this->swap(__other); } - packaged_task& operator=(packaged_task&& __other) noexcept { packaged_task(std::move(__other)).swap(*this); @@ -1577,10 +1581,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION packaged_task<_Res(_ArgTypes...)>& __y) noexcept { __x.swap(__y); } +#if __cplusplus < 201703L + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2976. Dangling uses_allocator specialization for packaged_task template struct uses_allocator, _Alloc> : public true_type { }; - +#endif // Shared state created by std::async(). // Holds a deferred function and storage for its result. diff --git a/libstdc++-v3/testsuite/30_threads/packaged_task/cons/alloc.cc b/libstdc++-v3/testsuite/30_threads/packaged_task/cons/alloc.cc index b806c0b8636..815ae0d25be 100644 --- a/libstdc++-v3/testsuite/30_threads/packaged_task/cons/alloc.cc +++ b/libstdc++-v3/testsuite/30_threads/packaged_task/cons/alloc.cc @@ -1,6 +1,5 @@ -// { dg-do run } +// { dg-do run { target { c++11_only || c++14_only } } } // { dg-options "-pthread" } -// { dg-require-effective-target c++11 } // { dg-require-effective-target pthread } // { dg-require-gthreads "" } diff --git a/libstdc++-v3/testsuite/30_threads/packaged_task/cons/alloc2.cc b/libstdc++-v3/testsuite/30_threads/packaged_task/cons/alloc2.cc index 4159d0088d9..06b60e546b2 100644 --- a/libstdc++-v3/testsuite/30_threads/packaged_task/cons/alloc2.cc +++ b/libstdc++-v3/testsuite/30_threads/packaged_task/cons/alloc2.cc @@ -1,4 +1,4 @@ -// { dg-do compile { target c++11 } } +// { dg-do compile { target { c++11_only || c++14_only } } } // { dg-require-gthreads "" } // Copyright (C) 2011-2019 Free Software Foundation, Inc. diff --git a/libstdc++-v3/testsuite/30_threads/packaged_task/cons/alloc_min.cc b/libstdc++-v3/testsuite/30_threads/packaged_task/cons/alloc_min.cc index 3ab1d1bd543..5ca0ba9ddb7 100644 --- a/libstdc++-v3/testsuite/30_threads/packaged_task/cons/alloc_min.cc +++ b/libstdc++-v3/testsuite/30_threads/packaged_task/cons/alloc_min.cc @@ -1,4 +1,4 @@ -// { dg-do compile { target c++11 } } +// { dg-do compile { target { c++11_only || c++14_only } } } // { dg-require-gthreads "" } // Copyright (C) 2011-2019 Free Software Foundation, Inc. diff --git a/libstdc++-v3/testsuite/30_threads/packaged_task/uses_allocator.cc b/libstdc++-v3/testsuite/30_threads/packaged_task/uses_allocator.cc index d251f89d5f4..5b1f244c960 100644 --- a/libstdc++-v3/testsuite/30_threads/packaged_task/uses_allocator.cc +++ b/libstdc++-v3/testsuite/30_threads/packaged_task/uses_allocator.cc @@ -1,4 +1,4 @@ -// { dg-do compile { target c++11 } } +// { dg-do compile { target { c++11_only || c++14_only } } } // { dg-require-gthreads "" } // Copyright (C) 2011-2019 Free Software Foundation, Inc.