Skip to content

[clang][bytecode] Clang produces incorrect mutable lambda code in presence of -fexperimental-new-constant-interpreter #164985

@BobIsOnFire

Description

@BobIsOnFire

Minimal repro:

#include <iostream>

int main() {
    auto foo = [a = false]() mutable {
        if (a) std::cout << ',';
        a = true;
        std::cout << 'A';
    };

    foo();
    foo();
}

https://godbolt.org/z/6nn4z4eqM

Looks like when -fexperimental-new-constant-interpreter is set, if (a) condition is optimized away completely, and -Wunreachable-code warning is emitted.

Didn't find anything similar in "clang:bytecode" open issues, but feel free to close if this is a duplicate.

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:bytecodeIssues for the clang bytecode constexpr interpreterconfirmedVerified by a second partylambdaC++11 lambda expressions

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions