Skip to content

Lambda-expression capturing structured bindings unexpected behaviour #59323

Closed
@ur4t

Description

@ur4t
$ 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:frontendLanguage frontend issues, e.g. anything involving "Sema"lambdaC++11 lambda expressions

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions