Wish: Split Wunused-lambda-capture

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Wish: Split Wunused-lambda-capture

Manuel Klimek via cfe-dev
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
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Wish: Split Wunused-lambda-capture

Manuel Klimek via cfe-dev
" 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:[hidden email]] On Behalf Of Tobias Hahn via cfe-dev
Sent: Thursday, April 5, 2018 8:50 AM
To: [hidden email]
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
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Wish: Split Wunused-lambda-capture

Manuel Klimek via cfe-dev
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 <[hidden email]>:
>
> " 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:[hidden email]] On Behalf Of Tobias Hahn via cfe-dev
> Sent: Thursday, April 5, 2018 8:50 AM
> To: [hidden email]
> 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
> [hidden email]
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
> _______________________________________________
> cfe-dev mailing list
> [hidden email]
> 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
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Wish: Split Wunused-lambda-capture

Manuel Klimek via cfe-dev
This was discussed when the warning was added. I felt the same way, but Aaron convinced me that this is short ("short") term pain:

We disabled the warning for now in Chromium.

On Thu, Apr 5, 2018 at 12:50 PM, Tobias Hahn via cfe-dev <[hidden email]> 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 <[hidden email]>:
>
> " 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:[hidden email]] On Behalf Of Tobias Hahn via cfe-dev
> Sent: Thursday, April 5, 2018 8:50 AM
> To: [hidden email]
> 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
> [hidden email]
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
> _______________________________________________
> cfe-dev mailing list
> [hidden email]
> 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
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev


_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Wish: Split Wunused-lambda-capture

Manuel Klimek via cfe-dev

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: [hidden email] [mailto:[hidden email]] On Behalf Of Nico Weber
Sent: Thursday, April 5, 2018 10:07 AM
To: Tobias Hahn <[hidden email]>
Cc: Keane, Erich <[hidden email]>; Clang Dev <[hidden email]>; Aaron Ballman <[hidden email]>
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:

 

We disabled the warning for now in Chromium.

 

On Thu, Apr 5, 2018 at 12:50 PM, Tobias Hahn via cfe-dev <[hidden email]> 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 <[hidden email]>:
>
> " 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:[hidden email]] On Behalf Of Tobias Hahn via cfe-dev
> Sent: Thursday, April 5, 2018 8:50 AM
> To: [hidden email]
> 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
> [hidden email]
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
> _______________________________________________
> cfe-dev mailing list
> [hidden email]
> 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
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev

 


_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Wish: Split Wunused-lambda-capture

Manuel Klimek via cfe-dev
In reply to this post by Manuel Klimek via cfe-dev

Further clarification, “Long Lived” (PM actually said ‘a while’ to me) means “weeks/months”, so consider that as you will.

 

From: Keane, Erich
Sent: Thursday, April 5, 2018 10:26 AM
To: Clang Dev <[hidden email]>
Subject: RE: [cfe-dev] Wish: Split Wunused-lambda-capture

 

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: [hidden email] [[hidden email]] On Behalf Of Nico Weber
Sent: Thursday, April 5, 2018 10:07 AM
To: Tobias Hahn <
[hidden email]>
Cc: Keane, Erich <
[hidden email]>; Clang Dev <[hidden email]>; Aaron Ballman <[hidden email]>
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:

 

We disabled the warning for now in Chromium.

 

On Thu, Apr 5, 2018 at 12:50 PM, Tobias Hahn via cfe-dev <[hidden email]> 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 <[hidden email]>:
>
> " 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:[hidden email]] On Behalf Of Tobias Hahn via cfe-dev
> Sent: Thursday, April 5, 2018 8:50 AM
> To: [hidden email]
> 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
> [hidden email]
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
> _______________________________________________
> cfe-dev mailing list
> [hidden email]
> 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
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev

 


_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev