http://llvm.org/bugs/show_bug.cgi?id=12566
Bug #: 12566
Summary: need warning for capturing and storing a ref to a
local in lambda
Product: clang
Version: trunk
Platform: All
OS/Version: All
Status: NEW
Severity: enhancement
Priority: P
Component: C++11
AssignedTo: [email protected]
ReportedBy: [email protected]
CC: [email protected], [email protected]
Classification: Unclassified
The following code should produce a warning for capturing and returning a ref
to the local n in foo():
#include <functional>
std::function<int()>
foo(int n) {
return [&]{ return n; };
}
int main() {
auto f = foo(5);
return f();
}
similar to the warning given when returning a pointer to a local:
warning: address of stack memory associated with local variable
'n' returned [-Wreturn-stack-address]
return &n;
--
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs