Can a lambda capturing nothing access global variables?
int n; int main() { [](){ n = 0; }(); // clang says "ok" int m; [](){ m = 0; }(); // clang says "not ok" } I just wonder: If the lambda captures nothing, is it allowed to access global variables as per the C++ standard? Yes, sure. Normal name lookup rules apply. [expr.prim.lambda]/7 ... for purposes of name lookup ... the compound-statement is considered in the context of the lambda-expression . Re: why local variables are treated differently from global ones. [expr.prim.lambda]/13 ... If a lambda-expression or an instantiation of the function call operator template of a generic lambda odr