[PATCH] D28467: [Sema] Add warning for unused lambda captures
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Wed Jan 18 19:47:02 PST 2017
On Jan 18, 2017 7:34 PM, "Akira Hatanaka via Phabricator" <
reviews at reviews.llvm.org> wrote:
ahatanak added a comment.
In https://reviews.llvm.org/D28467#649861, @krasin wrote:
> 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.
>
Is kDelta considered to be used in an unevaluated context here? I thought
unevaluated context in c++ means the expression is used as operands of
operators such as typeid and decltype.
It is not used in an unevaluated context -- that is a bug.
~Aaron
Repository:
rL LLVM
https://reviews.llvm.org/D28467
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170118/39f38652/attachment.html>
More information about the cfe-commits
mailing list