This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
Summary: | C++14: Variable captured with initializer by a lambda is unable to be resolved | ||
---|---|---|---|
Product: | cnd | Reporter: | Zcool31 |
Component: | Code Model | Assignee: | petrk |
Status: | NEW --- | ||
Severity: | normal | CC: | vertago1 |
Priority: | P3 | ||
Version: | 8.2 | ||
Hardware: | PC | ||
OS: | Linux | ||
Issue Type: | DEFECT | Exception Reporter: | |
Attachments: | code that demonstrates the same or related issue |
Description
Zcool31
2016-10-05 16:21:13 UTC
#include <iostream> using namespace std; void foo() { int bar = 1; auto lambda = [&bar = bar]() { bar = 10; cout << bar << endl; return bar; }; lambda(); cout << bar << endl; } int main() { foo(); return 0; } In "return bar;" line If I hold Ctrl key and click on 'bar' identifier, then cursor jumps to "int bar = 1;" line instead of "auto lambda = [&bar = bar]() {" Created attachment 163836 [details]
code that demonstrates the same or related issue
// This code also compiles fine but code assistance handles incorrectly.
// It may not be the same issue, but probably should be fixed at the same time.
#include <functional>
#include <iostream>
struct wrapper {
std::function<int(const std::string&)> callback;
};
int main() {
wrapper lambda_instance{[](const std::string& msg) -> int {
std::cout << msg <<"\n";
}};
return lambda_instance.callback("Hello World!");
}
Yes, the latter problem related to the uniform initialization syntax. Without it "msg" is resolved: int main() { wrapper lambda_instance = [](const std::string& msg) -> int { std::cout << msg <<"\n"; }; return lambda_instance.callback("Hello World!"); } I think, I'll file a separate bug for this later. |