Skip to content

Lambda-expression capturing structured bindings unexpected behaviour #59323

New issue

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

Closed
ur4t opened this issue Dec 3, 2022 · 3 comments
Closed

Lambda-expression capturing structured bindings unexpected behaviour #59323

ur4t opened this issue Dec 3, 2022 · 3 comments
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" lambda C++11 lambda expressions

Comments

@ur4t
Copy link
Contributor

ur4t commented Dec 3, 2022

$ clang++-16 --version
Debian clang version 16.0.0-++20221110071954+dd9f7963e434-1~exp1~20221110072047.450
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

Minimalist reproducible code snippet: https://godbolt.org/z/8f45heY19

#include <tuple>
int main() {
    auto [a, _] = std::make_tuple(1, 2);
    [&](int i) { a += 1; }(0);         // passed as expected.
    [&](auto i) { a += 1; }(0);        // should pass but not.
    [a](int i) { a += 1; }(0);         // should fail but not.
    [a](int i) mutable { a += 1; }(0); // passed as expected.
}

Not completely a duplicate of #57826, #58420 and #59015.

@EugeneZelenko EugeneZelenko added clang:frontend Language frontend issues, e.g. anything involving "Sema" and removed new issue labels Dec 3, 2022
@llvmbot
Copy link
Member

llvmbot commented Dec 3, 2022

@llvm/issue-subscribers-clang-frontend

@cor3ntin
Copy link
Contributor

cor3ntin commented Jan 9, 2023

Thanks.

I can confirm the 3rd case [a](int i) { a += 1; }(0); // should fail but not.) is still not handled correctly

@ur4t
Copy link
Contributor Author

ur4t commented Feb 23, 2025

This issue is the same as #95081 and fixed in #120849.

@ur4t ur4t closed this as completed Feb 23, 2025
@EugeneZelenko EugeneZelenko added the lambda C++11 lambda expressions label Feb 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" lambda C++11 lambda expressions
Projects
None yet
Development

No branches or pull requests

4 participants