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.
The following C++14 code is valid, but the IDE does not recognize the captured variable. void foo() { int bar = 1; auto baz = [quux = bar]()->void { // unable to resolve identifier quux static_cast<void>(quux); // unable to resolve identifier quux }; } Behavior is the same with multiple captures: void foo2() { int bar1 = 1; int bar2 = 2; auto baz = [quux1 = bar1, quux2 = bar2]()->void { // unable to resolve identifier quux1 // unable to resolve identifier quux2 }; }
#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.