Lambda capture by value timing

What does this print?

#include <iostream>
#include <functional>
int main() {
    int x = 1;
    auto f = [=]() { return x; };
    x = 42;
    std::cout << f();
}
A

Compile error

B

42

C

1

D

Undefined behavior