From patchwork Sat Aug 6 12:19:59 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 656362 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 3s62nL0sJjz9rxv for ; Sat, 6 Aug 2016 22:20:20 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=HLOpZA21; 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:references:mime-version:content-type :in-reply-to; q=dns; s=default; b=Z82n+3Mr6uaJWmpCwKAy0H+2FkIqg2 GswTaFuu2aBptR+3WkXus+JiTetLOdGDGrjmpv8gN86VawuAVgP0oJ05ItUMtpTV QnZ1Oh2iJ9WFUZyzcoaWS5WgdvLIYnoxVhODj4RbcmyXhXuNc4X2jZ04nOq4ItYz uFynuXNZu3Jus= 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:references:mime-version:content-type :in-reply-to; s=default; bh=gaTg7ClQqBnpnm7rfCQmeKNVbNY=; b=HLOp ZA21RgeXD6ZMart/RoncH9zqjzfgnw0QZFqHQhMdqtFGOS1FSDmacnzKBPIE1/C3 k4mIq3pLaeXPDFmmSnJ5TPsnudo6Z63iZoST9fiAMrEgX1APgDvJkPsRQbo8fdWh pKxOrPMIh3dPSFdA8oXNM0gQj6mXA89C47zgx9E= Received: (qmail 7513 invoked by alias); 6 Aug 2016 12:20:13 -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 7496 invoked by uid 89); 6 Aug 2016 12:20:13 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=BAYES_00, KAM_LAZY_DOMAIN_SECURITY, 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 (AES256-GCM-SHA384 encrypted) ESMTPS; Sat, 06 Aug 2016 12:20:03 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (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 EF16E4E320; Sat, 6 Aug 2016 12:20:00 +0000 (UTC) Received: from localhost (ovpn-116-26.ams2.redhat.com [10.36.116.26]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u76CK0Wg019265; Sat, 6 Aug 2016 08:20:00 -0400 Date: Sat, 6 Aug 2016 13:19:59 +0100 From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: Re: [PATCH] Use __invoke in std::function internals Message-ID: <20160806121959.GC9156@redhat.com> References: <20160805090018.GA5730@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20160805090018.GA5730@redhat.com> X-Clacks-Overhead: GNU Terry Pratchett User-Agent: Mutt/1.6.2 (2016-07-01) On 05/08/16 10:00 +0100, Jonathan Wakely wrote: >This fixes a bug in the _Callable SFINAE constraint of std::function, >where it was using an rvalue _Func in the result_of expression, when >the target is actually invoked as an lvalue. I'm backporting this part to gcc-5 and gcc-6. Tested x86_64-linux. commit 07adfca77ea9e69addccacb38f3f6ddf90c6bced Author: Jonathan Wakely Date: Sat Aug 6 12:50:56 2016 +0100 Use correct value category in std::function constraint * include/std/functional (function::_Callable): Use lvalue in result_of expression. * testsuite/20_util/function/cons/refqual.cc: New test. diff --git a/libstdc++-v3/include/std/functional b/libstdc++-v3/include/std/functional index 9799410..4f5b3c5 100644 --- a/libstdc++-v3/include/std/functional +++ b/libstdc++-v3/include/std/functional @@ -1847,7 +1847,7 @@ _GLIBCXX_MEM_FN_TRAITS(&&, false_type, true_type) typedef _Res _Signature_type(_ArgTypes...); template::type> + typename _Res2 = typename result_of<_Func&(_ArgTypes...)>::type> struct _Callable : __check_func_return_type<_Res2, _Res> { }; // Used so the return type convertibility checks aren't done when diff --git a/libstdc++-v3/testsuite/20_util/function/cons/refqual.cc b/libstdc++-v3/testsuite/20_util/function/cons/refqual.cc new file mode 100644 index 0000000..d3744ee --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/function/cons/refqual.cc @@ -0,0 +1,31 @@ +// Copyright (C) 2016 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-options "-std=gnu++11" } + +#include + +struct F { + void operator()() && { } + int operator()() & { return 0; } +}; + +int main() { + F f; + std::function ff{f}; + return ff(); +}