dimanche 2 août 2020

GCC leaking its lambda implementation into the user's program?

How is it possible that the following code is successfully compiled by GCC version [6..10] ?

int main(int argc, char *argv[])
{
    auto const answer = 42;
    auto lambda = [&answer] {};
    auto *p = &(lambda.__answer);

    return p != &answer; // return 0 (success) if they are the same
}

Is GCC leaking its internal representation of lambdas into the user's program?

godbolt

Aucun commentaire:

Enregistrer un commentaire