Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(64)

Issue 2653683005: Reenable -Wunused-lambda-capture warning.

Created:
3 years, 11 months ago by krasin1
Modified:
3 years, 11 months ago
Reviewers:
Dirk Pranke, dpranke, Nico
CC:
chromium-reviews
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Reenable -Wunused-lambda-capture warning. This warning has been recently introduced into Clang, and a lot of Clang ToT bots went red because Chromium had a number of cases where lambdas had unused lambdas. Note: there is an annoying bug in MSVC++ regarding to capturing const values. Consider the code like: const int N = 3; auto g = [N](){ printf("%d\n", N); }; g(); Clang will issue a warning that N capture is unused. Okay, we remove it: const int N = 3; auto g = [](){ printf("%d\n", N); }; g(); but then MSVC++ is unhappy. And that's a bug in MSVC++, see https://social.msdn.microsoft.com/Forums/SqlServer/4abf18bd-4ae4-4c72-ba3e-3b... http://connect.microsoft.com/VisualStudio/feedback/details/725780/lambda-expr... (will require to sign in, and might not show its contents anyway) http://wap.cpp.forum24.ru/?1-3-0-00000034-000-0-0 (in Russian; by the author of the original bug report to Microsoft, Сыроежка) The workaround is to have such constants static: static const int N = 3; auto g = [](){ printf("%d\n", N); }; g(); The cleanup is now complete, and it's time to reenable the warning. I have tested it on Linux x86-64 by building All targets. They succeeded. Theoretically, some platform-specific code might still have issues like that, but it should be trivial to fix them, when they are detected by Clang ToT bots. BUG=681136

Patch Set 1 #

Unified diffs Side-by-side diffs Delta from patch set Stats (+0 lines, -3 lines) Patch
M build/config/compiler/BUILD.gn View 1 chunk +0 lines, -3 lines 0 comments Download

Messages

Total messages: 14 (8 generated)
krasin1
3 years, 11 months ago (2017-01-24 21:35:36 UTC) #2
Nico
How often did you run into the constexpr thing? If that's at all common, then ...
3 years, 11 months ago (2017-01-24 21:38:51 UTC) #6
krasin1
On 2017/01/24 21:38:51, Nico wrote: > How often did you run into the constexpr thing? ...
3 years, 11 months ago (2017-01-24 21:50:13 UTC) #7
Dirk Pranke
I defer to Nico here.
3 years, 11 months ago (2017-01-24 21:53:01 UTC) #9
Nico
Do you have a rough estimate how many non-const unused captures you removed? Is it ...
3 years, 11 months ago (2017-01-24 22:06:47 UTC) #10
krasin1
3 years, 11 months ago (2017-01-24 22:12:30 UTC) #12
On 2017/01/24 22:06:47, Nico wrote:
> Do you have a rough estimate how many non-const unused captures you removed?
Is
> it closer to 3 in 30 or 3 in 100 (or lower)?
It's about 3 in 30, yes.

> 
> (I'd change the CL description to mention this caveat and the recommended
> workaround; that bit of information is probably more interesting to future
> people than the history which is already in the bug.)
Done.

> 
> Rollout plan: Maybe it makes sense to wait for the next clang roll and then
turn
> it on after that? Else the next clang roll will update both the compiler and
> (implicitly) turn on this warning, which increases roll risk. And once the
> compiler is rev'd, this CL can be tested on the try bots. (I'm not sure this
is
> necessary, but it kind of feels like it might be a good idea.)

Sure, it makes sense. Let's not proceed with this CL at this time. Then, whoever
makes a roll, will disable the warning for all (not just ToT bots). And then
we'll enable it by running a proper CQ.

Powered by Google App Engine
This is Rietveld 408576698