[cfe-dev] Wish: Split Wunused-lambda-capture

Keane, Erich via cfe-dev cfe-dev at lists.llvm.org
Thu Apr 5 10:25:49 PDT 2018


I just got word back from a PM at Microsoft, apparently fixing this bug is not an easy one (seemingly would require architectural changes), and so this is likely going to be a long lived bug in MSVC.

I tend to agree completely with Aaron in that thread, but I wanted to make sure we have this context in case we revisit.

-Erich

From: thakis at google.com [mailto:thakis at google.com] On Behalf Of Nico Weber
Sent: Thursday, April 5, 2018 10:07 AM
To: Tobias Hahn <tobias.hahn at ableton.com>
Cc: Keane, Erich <erich.keane at intel.com>; Clang Dev <cfe-dev at lists.llvm.org>; Aaron Ballman <aaron.ballman at gmail.com>
Subject: Re: [cfe-dev] Wish: Split Wunused-lambda-capture

This was discussed when the warning was added. I felt the same way, but Aaron convinced me that this is short ("short") term pain:
http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20170116/183259.html
https://marc.info/?l=cfe-commits&m=148521057007058&w=2
https://marc.info/?l=cfe-commits&m=148546938216504&w=2

We disabled the warning for now in Chromium.

On Thu, Apr 5, 2018 at 12:50 PM, Tobias Hahn via cfe-dev <cfe-dev at lists.llvm.org<mailto:cfe-dev at lists.llvm.org>> wrote:
I did that as well as posting my wish here, let's see...

T

> Am 05.04.2018 um 17:54 schrieb Keane, Erich via cfe-dev <cfe-dev at lists.llvm.org<mailto:cfe-dev at lists.llvm.org>>:
>
> " Since I don't expect MSVC to be standards compliant any time soon,"
>
> I think you may wish to report this as a bug to the MSVC team.  They have been REALLY good about fixing standards compliance issues in the past two years or so.
>
> -----Original Message-----
> From: cfe-dev [mailto:cfe-dev-bounces at lists.llvm.org<mailto:cfe-dev-bounces at lists.llvm.org>] On Behalf Of Tobias Hahn via cfe-dev
> Sent: Thursday, April 5, 2018 8:50 AM
> To: cfe-dev at lists.llvm.org<mailto:cfe-dev at lists.llvm.org>
> Subject: [cfe-dev] Wish: Split Wunused-lambda-capture
>
> In migrating our codebase to Xcode 9.3, I came across the new warning -Wunused-lambda-capture. This seems like a helpful warning to enable; yet unfortunately I cannot due to incompatibility with MSVC.
>
> The problem is that it warns on the following code (https://godbolt.org/g/HDiqR8):
>
> int times2(int num) {
>  const int two = 2;
>  auto multiply = [two](int i) { return i * two; };
>  return multiply(num);
> }
>
> Per the standard, it is unnecessary to capture `two` because it is an integral constant. MSVC doesn't know about this, and throws C3493 (variable cannot be implicitly captured) if I remove `two` from the capture clause to fix clang's -Wunused-lambda-capture (https://godbolt.org/g/VNNfqT).
>
> Since I don't expect MSVC to be standards compliant any time soon, it would be great if this warning could be split into two warnings:
>
> -Wunused-lambda-capture would only warn on truly unused captures, but not captures that are merely unnecessary (but still used as in the example above).
>
> -Wunnecessary-lambda-capture would warn on redundant explicit captures (as in the example above).
>
> Thanks for considering my wish and making clang even better!
>
> Tobias
>
> Ableton AG, Schoenhauser Allee 6-7, 10119 Berlin, Germany Sitz (Registered Office) Berlin, Amtsgericht Berlin-Charlottenburg, HRB 72838 Vorstand (Management Board): Gerhard Behles, Jan Bohl Vorsitzender des Aufsichtsrats (Chair of the Supervisory Board): Uwe Struck
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org<mailto:cfe-dev at lists.llvm.org>
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org<mailto:cfe-dev at lists.llvm.org>
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev

Ableton AG, Schoenhauser Allee 6-7, 10119 Berlin, Germany
Sitz (Registered Office) Berlin, Amtsgericht Berlin-Charlottenburg, HRB 72838
Vorstand (Management Board): Gerhard Behles, Jan Bohl
Vorsitzender des Aufsichtsrats (Chair of the Supervisory Board): Uwe Struck


_______________________________________________
cfe-dev mailing list
cfe-dev at lists.llvm.org<mailto:cfe-dev at lists.llvm.org>
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20180405/77e3a57d/attachment-0001.html>


More information about the cfe-dev mailing list