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

Issue 2701313007: Fix clang compiler warning for lambda variable catpure (Closed)

Created:
3 years, 10 months ago by etienneb
Modified:
3 years, 10 months ago
CC:
chromium-reviews, tracing+reviews_chromium.org, wfh+watch_chromium.org, vmpstr+watch_chromium.org
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

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/slot-set-unittest.cc BUG=

Patch Set 1 #

Unified diffs Side-by-side diffs Delta from patch set Stats (+1 line, -2 lines) Patch
M base/trace_event/memory_dump_manager_unittest.cc View 1 chunk +1 line, -2 lines 0 comments Download

Messages

Total messages: 15 (5 generated)
etienneb
PTAL & CQ
3 years, 10 months ago (2017-02-22 19:08:22 UTC) #3
Primiano Tucci (use gerrit)
lgtm
3 years, 10 months ago (2017-02-23 14:51:10 UTC) #4
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2701313007/1
3 years, 10 months ago (2017-02-23 14:51:35 UTC) #6
commit-bot: I haz the power
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_compile_dbg_ng/builds/354599) win_chromium_rel_ng on master.tryserver.chromium.win (JOB_FAILED, ...
3 years, 10 months ago (2017-02-23 15:04:15 UTC) #8
etienneb
This is fun, we need to choose between which error we want! MSVC and Clang ...
3 years, 10 months ago (2017-02-23 15:35:46 UTC) #9
Primiano Tucci (use gerrit)
On 2017/02/23 15:35:46, etienneb wrote: > This is fun, we need to choose between which ...
3 years, 10 months ago (2017-02-23 15:49:49 UTC) #10
etienneb
On 2017/02/23 15:49:49, Primiano Tucci wrote: > On 2017/02/23 15:35:46, etienneb wrote: > > This ...
3 years, 10 months ago (2017-02-23 15:55:19 UTC) #12
Nico
On 2017/02/23 15:55:19, etienneb wrote: > On 2017/02/23 15:49:49, Primiano Tucci wrote: > > On ...
3 years, 10 months ago (2017-02-23 15:58:25 UTC) #13
etienneb
On 2017/02/23 15:58:25, Nico wrote: > On 2017/02/23 15:55:19, etienneb wrote: > > On 2017/02/23 ...
3 years, 10 months ago (2017-02-23 16:04:56 UTC) #14
etienneb
3 years, 10 months ago (2017-02-23 16:06:13 UTC) #15
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

Powered by Google App Engine
This is Rietveld 408576698