Open
Description
#include <algorithm>
#include <functional>
auto foo(int x) {
return [&]() { return x + 1; }; // good, give a warning.
}
std::function<int()> foo2(int x) {
return [&]() { return x + 1; }; // no warning
}
auto foo3(int x) {
auto a = [&]() { return x + 1;};
return a; // no warning.
}
https://godbolt.org/z/nfacaEfGM, it would be good to detect case 2 and case 3.