[llvm-bugs] [Bug 31815] New: spurious Wunused-lambda-capture warning?
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue Jan 31 06:47:17 PST 2017
https://llvm.org/bugs/show_bug.cgi?id=31815
Bug ID: 31815
Summary: spurious Wunused-lambda-capture warning?
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: C++14
Assignee: unassignedclangbugs at nondot.org
Reporter: rhalbersma at gmail.com
CC: llvm-bugs at lists.llvm.org
Classification: Unclassified
#include <iostream>
auto sq(int c, int x) { return c * x * x; }
struct S {
template<class Fun>
void for_each(Fun fun) const {
for (auto i = 1; i < 4; ++i) {
fun(i);
}
}
};
int main()
{
S s;
auto sum = 0;
s.for_each([&, i = 2](auto c) mutable {
sum += sq(c, i++);
});
std::cout << sum; // 70 = 1 * 4 + 2 * 9 + 3 * 16
}
Works with clang up to 4.0 and gcc up to 7.0 SVN. Gives -Wunused-lambda-capture
for Clang 5.0 SVN tip-of-trunk
See also http://stackoverflow.com/q/41960347/819272
--
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/20170131/739a970e/attachment.html>
More information about the llvm-bugs
mailing list