Skip to content

[Clang] Deducing this Lambda does not generate all the needed function calls #86399

Closed
@Link1J

Description

@Link1J

Found when reporting #86398, so it may be related to it.
But with the following valid code, at all optimization levels, the following code does not generate correctly.

volatile int a = 0;
struct function {
    function& operator=(function const&) {
        a = 1;
        return *this;
    }
};
int main() {
    function list;
    [&list](this auto self) {
        list = function{};
    }();
}

Clang does not generate a call to function::operator=, and therefor does not set a to 1.
Both GCC and MSVC generate the code correctly.
Godbolt

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:frontendLanguage frontend issues, e.g. anything involving "Sema"confirmedVerified by a second partylambdaC++11 lambda expressions

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions