From patchwork Mon Feb 13 13:14:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 727303 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 3vMQyn74JYz9s7t for ; Tue, 14 Feb 2017 00:15:26 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="CApfaFXR"; dkim-atps=neutral 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=wszXKdpIEvYkVPY5J9dVQnhxaxitDIoTbMNeTqxJYBDsqR2SCYd80 YWmhhKOgncNDDOpRCyWNRSrX7yFn+HFyAJ+7PzNZGNEUT0aKf42XMDsGmtn0ior+ IuvB/RwRkuQ3sA7JV4FDna66fx9z5jP1+s/AnBeKWRgORP3uVf4Mh0= 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=Y9PgfWDJDwcjC/L0Cn95tP0t6pQ=; b=CApfaFXRsUqCV0vtUVNf vN2Xm3BcItTVULkfE1cZdrL/B74yDp4uyqJFKZznhK238faP9vyh8CZr7gn5vAUh iZXTtSNCqk5naMEwc4r3Zii+vJpsrBC7Onybn4LvegzN7LOvNlv4V4WSPtjpnJaR 7ZpMDsZZijpQ+XSlN97tvtg= Received: (qmail 95999 invoked by alias); 13 Feb 2017 13:15:03 -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 95920 invoked by uid 89); 13 Feb 2017 13:15:01 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= X-Spam-User: qpsmtpd, 2 recipients 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; Mon, 13 Feb 2017 13:15:00 +0000 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3405B15552; Mon, 13 Feb 2017 13:15:00 +0000 (UTC) Received: from localhost (ovpn-116-31.ams2.redhat.com [10.36.116.31]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1DDEwiX008729; Mon, 13 Feb 2017 08:14:59 -0500 Date: Mon, 13 Feb 2017 13:14:57 +0000 From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [PATCH] PR libstdc++/79486 use lvalues in result_of expressions Message-ID: <20170213131457.GA15131@redhat.com> MIME-Version: 1.0 Content-Disposition: inline X-Clacks-Overhead: GNU Terry Pratchett User-Agent: Mutt/1.7.1 (2016-10-04) This is a similar bug to the is_callable assertions I fixed in shared_ptr the other day: it needs to use the correct value category in the result_of type. This is also a regression, in code that has been refactored on trunk. PR libstdc++/79486 * include/std/future (__future_base::_Task_state::_M_run) (__future_base::_Task_state::_M_run_delayed): Use lvalue types in result_of expressions. * testsuite/30_threads/packaged_task/79486.cc: New. Tested powerpc64le-linux, committed to trunk. commit 10639bc87b988d5cdac07fc905fe4d8c800a6283 Author: Jonathan Wakely Date: Mon Feb 13 12:51:51 2017 +0000 PR libstdc++/79486 use lvalues in result_of expressions PR libstdc++/79486 * include/std/future (__future_base::_Task_state::_M_run) (__future_base::_Task_state::_M_run_delayed): Use lvalue types in result_of expressions. * testsuite/30_threads/packaged_task/79486.cc: New. diff --git a/libstdc++-v3/include/std/future b/libstdc++-v3/include/std/future index 6351d7e..cb53561 100644 --- a/libstdc++-v3/include/std/future +++ b/libstdc++-v3/include/std/future @@ -1416,7 +1416,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION virtual void _M_run(_Args&&... __args) { - auto __boundfn = [&] () -> typename result_of<_Fn(_Args&&...)>::type { + auto __boundfn = [&] () -> typename result_of<_Fn&(_Args&&...)>::type { return std::__invoke(_M_impl._M_fn, std::forward<_Args>(__args)...); }; this->_M_set_result(_S_task_setter(this->_M_result, __boundfn)); @@ -1425,7 +1425,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION virtual void _M_run_delayed(_Args&&... __args, weak_ptr<_State_base> __self) { - auto __boundfn = [&] () -> typename result_of<_Fn(_Args&&...)>::type { + auto __boundfn = [&] () -> typename result_of<_Fn&(_Args&&...)>::type { return std::__invoke(_M_impl._M_fn, std::forward<_Args>(__args)...); }; this->_M_set_delayed_result(_S_task_setter(this->_M_result, __boundfn), diff --git a/libstdc++-v3/testsuite/30_threads/packaged_task/79486.cc b/libstdc++-v3/testsuite/30_threads/packaged_task/79486.cc new file mode 100644 index 0000000..46b4f3d --- /dev/null +++ b/libstdc++-v3/testsuite/30_threads/packaged_task/79486.cc @@ -0,0 +1,27 @@ +// Copyright (C) 2017 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// { dg-do compile { target c++11 } } + +#include + +struct F { + void operator()() & { } + void operator()() && = delete; // PR libstdc++/79486 +}; + +std::packaged_task t{F{}};