While speaking with a colleague of mine, they said that:
foo() { int *p; { int x = 5; p = &x; } int y = *p; }
creates undefined behavior because lifetime rules and scope rules do not specify.
However:
foo() { int *p; { static int x = 5; p = &x; } int y = *p; }
is not undefined! You end up with "indirect scoping" issues.
The use of terminology does not sound correct.
I know that static has nothing to do with scoping.
Is it true that the second case has defined behavior?