From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 78692 invoked by alias); 18 Apr 2015 17:53:34 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 78679 invoked by uid 89); 18 Apr 2015 17:53:33 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=1.1 required=5.0 tests=AWL,BAYES_20,KAM_COUK,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_DNSWL_LOW autolearn=no version=3.3.2 X-HELO: avasout03.plus.net Received: from avasout03.plus.net (HELO avasout03.plus.net) (84.93.230.244) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Sat, 18 Apr 2015 17:53:32 +0000 Received: from webmail.plus.net ([84.93.228.147]) by avasout03 with smtp id HVtU1q0013BT6uC01VtU5a; Sat, 18 Apr 2015 18:53:28 +0100 X-CM-Score: 0.00 X-CNFS-Analysis: v=2.1 cv=KoDD2AmN c=1 sm=1 tr=0 a=jSQgp9IWXRf89EXR5FPwJg==:117 a=8YZdF9bm7lDkcydB81w8Xw==:17 a=0Bzu9jTXAAAA:8 a=dYCPD3cKDi0A:10 a=jPJDawAOAc8A:10 a=vpjNtYboqT8A:10 a=IkcTkHD0fZMA:10 a=ZBkl__CYAAAA:8 a=mrHjP8x4AAAA:8 a=7vtFykjVAAAA:8 a=e9J7MTPGsLIA:10 a=7EYdjTbhYsklY88YTPUA:9 a=QEXdDO2ut3YA:10 X-AUTH: jessaminenet+adam@:2501 Received: from munkyhouse.force9.co.uk ([84.92.42.80]) by webmail.plus.net with HTTP (HTTP/1.1 POST); Sat, 18 Apr 2015 18:53:28 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Date: Sat, 18 Apr 2015 17:53:00 -0000 From: Adam Butcher To: Jason Merrill Cc: gcc-patches Subject: Re: [PATCH 1/2] =?UTF-8?Q?=09PR=20c++/=36=31=36=33=36?= In-Reply-To: References: <1428636694-6767-1-git-send-email-adam@jessamine.co.uk> <1428636694-6767-2-git-send-email-adam@jessamine.co.uk> <553165EA.70700@redhat.com> Message-ID: <2c51b8076a5ca562f87d7ba0ac8d5a70@imap.force9.net> X-Sender: adam@jessamine.co.uk User-Agent: Roundcube Webmail/0.7.4 X-SW-Source: 2015-04/txt/msg00959.txt.bz2 On 2015-04-17 22:06, Adam Butcher wrote: > On 2015-04-17 20:58, Jason Merrill wrote: >> On 04/09/2015 11:31 PM, Adam Butcher wrote: >>> + /* For generic lambdas, resolve default captured 'this' now. */ >>> >> This isn't quite right. We don't want to capture 'this' any time we >> see a member function call, as overload resolution might choose a >> static member function that doesn't need 'this'. The special >> handling >> we want is for the case where the call depends on a generic lambda >> parameter, in which case we capture 'this' because the call "names >> [this] in a potentially-evaluated expression (3.2) where the >> enclosing >> full-expression depends on a generic lambda parameter declared >> within >> the reaching scope of the lambda-expression." >> > Good point. I'll look into it. So for a nullary member call we will > always capture 'this', but for N-ary, we only capture if we find one > of the lambda's parameters (or a parameter from an enclosing generic > lambda?) in the call's arguments right? > Test like this? /* { dg-do run { target c++14 } } */ /* { dg-final { scan-assembler-not "..." } } */ struct X { int f (int, double) { return 255; } static int f (int, int) { return 65535; } auto m1 () { return [=] (auto a) { return f (7, a); }; } auto m2 () { return [=] (auto a) { return f (9, 10) + a; }; } }; #include int main() { X x; assert (x.m1 () (42.0) == 255); assert (x.m1 () (42) == 65535); assert (x.m2 () (42.0) == (65535 + 42)); assert (x.m2 () (42) == (65535 + 42)); assert (sizeof x.m2 () < sizeof x.m1 ()); }