Behaviour of a lambda expression used in static initializers magically depends on local variables initialized inside lambda body
int static_1 =
[=]() -> int {
int k_=7;// if this statement presents, the lambda doesn't work (static_1 remains uninitialized)
return 5;
} ();
int static_2=
[=]() -> int {
//Ok without variable initializer int k_=7;
return 5;
}();
int main() {
int local=
[=]() -> int {
int k_=7; // Ok with variable initializer when lambda used in local function context
return 5;
} ();
printf("\n static_1= %d \n static_2= %d \n local= %d", static_1,static_2,local);
}