We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue: The generated code for a lambda function that captures a variable by value does not use the captured variable in the lambda body.
Example Code:
int main() { int z{5}; auto sum = [z](int x, int y){ return x + y + z; }; }
Generated Code
int main() { int z = {5}; class __lambda_7_16 { public: inline /*constexpr */ int operator()(int x, int y) const { return (x + y) + x; } private: int z; public: __lambda_7_16(int & _z) : z{_z} {} }; __lambda_7_16 sum = __lambda_7_16{z}; return 0; }
Expected Generated Code
int main() { int z = {5}; class __lambda_7_16 { public: inline /*constexpr */ int operator()(int x, int y) const { return (x + y) + z; // Correct: `z` is used here } private: int z; public: __lambda_7_16(int & _z) : z{_z} {} }; __lambda_7_16 sum = __lambda_7_16{z}; return 0; }
Note The issue seems to be intermittent, and it may not reproduce consistently.
The text was updated successfully, but these errors were encountered:
Hello @glucu,
thanks for reporting this issue! After a couple of days and tries, I was not able to reproduce it. Are you running a self-build version?
Andreas
Sorry, something went wrong.
Hi @andreasfertig
I also tested further and was unable to reproduce the problem. Odd. This was run on cppinsights.io.
No branches or pull requests
Issue:
The generated code for a lambda function that captures a variable by value does not use the captured variable in the lambda body.
Example Code:
Generated Code
Expected Generated Code
Note
The issue seems to be intermittent, and it may not reproduce consistently.
The text was updated successfully, but these errors were encountered: