[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
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: 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
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.
-------------- 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