|
|
DescriptionFix clang compiler warning for lambda variable catpure
This is broken with a recent clang compiler.
This warning got introduced by clang (5.0.0) with this commit:
https://reviews.llvm.org/D28467
Other recent similar fixes in chrome:
https://codereview.chromium.org/2646553002/diff/20001/test/unittests/heap/slot-set-unittest.cc
BUG=
Patch Set 1 #
Messages
Total messages: 15 (5 generated)
Description was changed from ========== Fix clang compiler warning for lambda variable catpure This is broken with a recent clang compiler. This warning got introduced by clang (5.0.0) with this commit: https://reviews.llvm.org/D28467 Other recent similar fixes in chrome: https://codereview.chromium.org/2646553002/diff/20001/test/unittests/heap/slo... BUG= ========== to ========== Fix clang compiler warning for lambda variable catpure This is broken with a recent clang compiler. This warning got introduced by clang (5.0.0) with this commit: https://reviews.llvm.org/D28467 Other recent similar fixes in chrome: https://codereview.chromium.org/2646553002/diff/20001/test/unittests/heap/slo... BUG= ==========
etienneb@chromium.org changed reviewers: + primiano@chromium.org
PTAL & CQ
lgtm
The CQ bit was checked by primiano@chromium.org
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Try jobs failed on following builders: win_chromium_compile_dbg_ng on master.tryserver.chromium.win (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.win/builders/win_chromium_comp...) win_chromium_rel_ng on master.tryserver.chromium.win (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.win/builders/win_chromium_rel_...)
This is fun, we need to choose between which error we want! MSVC and Clang won't output the same error. e:\b\c\b\win\src\base\trace_event\memory_dump_manager_unittest.cc(783): error C3493: 'kPollsToQuit' cannot be implicitly captured because no default capture mode has been specified
On 2017/02/23 15:35:46, etienneb wrote: > This is fun, we need to choose between which error we want! > MSVC and Clang won't output the same error. > > e:\b\c\b\win\src\base\trace_event\memory_dump_manager_unittest.cc(783): error > C3493: 'kPollsToQuit' cannot be implicitly captured because no default capture > mode has been specified The fact that they cannot agree on how to pass a constant to a lambda is extremely amusing. :) Good luck
etienneb@chromium.org changed reviewers: + chrisha@chromium.org, rnk@chromium.org, thakis@chromium.org
On 2017/02/23 15:49:49, Primiano Tucci wrote: > On 2017/02/23 15:35:46, etienneb wrote: > > This is fun, we need to choose between which error we want! > > MSVC and Clang won't output the same error. > > > > e:\b\c\b\win\src\base\trace_event\memory_dump_manager_unittest.cc(783): error > > C3493: 'kPollsToQuit' cannot be implicitly captured because no default capture > > mode has been specified > The fact that they cannot agree on how to pass a constant to a lambda is > extremely amusing. :) > Good luck The example on the original thread is showing this case: https://reviews.llvm.org/D28467 """ This change makes Clang hardly incompatible with MSVC++. Consider the following program: #include <stdio.h> int main(void) { const int kDelta = 10000001; auto g = [kDelta](int i) { printf("%d\n", i % kDelta); }; g(2); } Clang will warn about the unused lambda capture: $ clang++ lala.cc -o lala -std=c++14 -Wall -Werror && ./lala lala.cc:5:13: error: lambda capture 'kDelta' is not required to be captured for use in an unevaluated context [-Werror,-Wunused-lambda-capture] auto g = [kDelta](int i) ^ 1 error generated. """
On 2017/02/23 15:55:19, etienneb wrote: > On 2017/02/23 15:49:49, Primiano Tucci wrote: > > On 2017/02/23 15:35:46, etienneb wrote: > > > This is fun, we need to choose between which error we want! > > > MSVC and Clang won't output the same error. > > > > > > e:\b\c\b\win\src\base\trace_event\memory_dump_manager_unittest.cc(783): > error > > > C3493: 'kPollsToQuit' cannot be implicitly captured because no default > capture > > > mode has been specified > > The fact that they cannot agree on how to pass a constant to a lambda is > > extremely amusing. :) > > Good luck > > The example on the original thread is showing this case: > https://reviews.llvm.org/D28467 > > """ > This change makes Clang hardly incompatible with MSVC++. Consider the following > program: > > #include <stdio.h> > > int main(void) { > const int kDelta = 10000001; > auto g = [kDelta](int i) > { > printf("%d\n", i % kDelta); > }; > g(2); > } > Clang will warn about the unused lambda capture: > > $ clang++ lala.cc -o lala -std=c++14 -Wall -Werror && ./lala > lala.cc:5:13: error: lambda capture 'kDelta' is not required to be captured for > use in an unevaluated context [-Werror,-Wunused-lambda-capture] > auto g = [kDelta](int i) > ^ > 1 error generated. > """ Why is this needed? We disable this warning for this reason. If you want to build chrome with trunk clang you need to set use_llvm_head (or similar, don't remember the spelling) to get warning flags that work with trunk.
On 2017/02/23 15:58:25, Nico wrote: > On 2017/02/23 15:55:19, etienneb wrote: > > On 2017/02/23 15:49:49, Primiano Tucci wrote: > > > On 2017/02/23 15:35:46, etienneb wrote: > > > > This is fun, we need to choose between which error we want! > > > > MSVC and Clang won't output the same error. > > > > > > > > e:\b\c\b\win\src\base\trace_event\memory_dump_manager_unittest.cc(783): > > error > > > > C3493: 'kPollsToQuit' cannot be implicitly captured because no default > > capture > > > > mode has been specified > > > The fact that they cannot agree on how to pass a constant to a lambda is > > > extremely amusing. :) > > > Good luck > > > > The example on the original thread is showing this case: > > https://reviews.llvm.org/D28467 > > > > """ > > This change makes Clang hardly incompatible with MSVC++. Consider the > following > > program: > > > > #include <stdio.h> > > > > int main(void) { > > const int kDelta = 10000001; > > auto g = [kDelta](int i) > > { > > printf("%d\n", i % kDelta); > > }; > > g(2); > > } > > Clang will warn about the unused lambda capture: > > > > $ clang++ lala.cc -o lala -std=c++14 -Wall -Werror && ./lala > > lala.cc:5:13: error: lambda capture 'kDelta' is not required to be captured > for > > use in an unevaluated context [-Werror,-Wunused-lambda-capture] > > auto g = [kDelta](int i) > > ^ > > 1 error generated. > > """ > > Why is this needed? We disable this warning for this reason. If you want to > build chrome with trunk clang you need to set use_llvm_head (or similar, don't > remember the spelling) to get warning flags that work with trunk. FLAG: llvm_force_head_revision
On 2017/02/23 16:04:56, etienneb wrote: > On 2017/02/23 15:58:25, Nico wrote: > > On 2017/02/23 15:55:19, etienneb wrote: > > > On 2017/02/23 15:49:49, Primiano Tucci wrote: > > > > On 2017/02/23 15:35:46, etienneb wrote: > > > > > This is fun, we need to choose between which error we want! > > > > > MSVC and Clang won't output the same error. > > > > > > > > > > e:\b\c\b\win\src\base\trace_event\memory_dump_manager_unittest.cc(783): > > > error > > > > > C3493: 'kPollsToQuit' cannot be implicitly captured because no default > > > capture > > > > > mode has been specified > > > > The fact that they cannot agree on how to pass a constant to a lambda is > > > > extremely amusing. :) > > > > Good luck > > > > > > The example on the original thread is showing this case: > > > https://reviews.llvm.org/D28467 > > > > > > """ > > > This change makes Clang hardly incompatible with MSVC++. Consider the > > following > > > program: > > > > > > #include <stdio.h> > > > > > > int main(void) { > > > const int kDelta = 10000001; > > > auto g = [kDelta](int i) > > > { > > > printf("%d\n", i % kDelta); > > > }; > > > g(2); > > > } > > > Clang will warn about the unused lambda capture: > > > > > > $ clang++ lala.cc -o lala -std=c++14 -Wall -Werror && ./lala > > > lala.cc:5:13: error: lambda capture 'kDelta' is not required to be captured > > for > > > use in an unevaluated context [-Werror,-Wunused-lambda-capture] > > > auto g = [kDelta](int i) > > > ^ > > > 1 error generated. > > > """ > > > > Why is this needed? We disable this warning for this reason. If you want to > > build chrome with trunk clang you need to set use_llvm_head (or similar, don't > > remember the spelling) to get warning flags that work with trunk. > > FLAG: llvm_force_head_revision Ok, it seems to work. I'm closing this CL. """ if (llvm_force_head_revision) { cflags += [ # TODO(hans): https://crbug.com/681136 "-Wno-unused-lambda-capture", # TODO(thakis ): https://crbug.com/683349 "-Wno-user-defined-warnings", ] } """ Thanks nico |