[PATCH] D28467: [Sema] Add warning for unused lambda captures
Akira Hatanaka via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Jan 18 16:34:20 PST 2017
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.
Repository:
rL LLVM
https://reviews.llvm.org/D28467
More information about the cfe-commits
mailing list