https://bugs.llvm.org/show_bug.cgi?id=41623

            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: unassignedclangb...@nondot.org
          Reporter: jva...@gmail.com
                CC: htmldevelo...@gmail.com, llvm-bugs@lists.llvm.org,
                    neeil...@live.com, richard-l...@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
captured.
Removing it, results however in a compilation failure with MSVC 2017.

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

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

Warning:
--------
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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to