[llvm-bugs] [Bug 41623] New: -Wunused-lambda-capture on const variable

via llvm-bugs llvm-bugs at lists.llvm.org
Sat Apr 27 00:25:30 PDT 2019


            Bug ID: 41623
           Summary: -Wunused-lambda-capture on const variable
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: jvapen at gmail.com
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org,
                    neeilans at live.com, richard-llvm at metafoo.co.uk

Reproduction on compiler explorer: https://gcc.godbolt.org/z/OEYl7K

In the example below, Clang (7.0.0 and trunk) do not require 'c' to be
Removing it, results however in a compilation failure with MSVC 2017.

bool f()
    const auto c = 42;
    return [c](int v) { return v == c; }(42);

clang++ -O3  -std=c++2a -Wunused-lambda-capture t.cpp
cl /O2 t.cpp

t.cpp:5:13: warning: lambda capture 'c' is not required to be captured for this
use [-Wunused-lambda-capture]

    return [c](int v) { return v == c; }(42);


1 warning generated.

You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190427/3d39771d/attachment.html>

More information about the llvm-bugs mailing list