The issue is a little bit subtle; please refer to C++11 3.6.2 for details.
What matters for us is that there are two phases of initialization of “non-local variables with static storage duration” (or “global variables” in colloquial parlance): the static initialization phase and the dynamic initialization phase. The static phase comes first. It looks like this:
int a = 0;
int x = 22;
The dynamic initialization runs afterwards:
a = f();
The point is that static initialization doesn’t “run” at all – it only consists of setting values that are known at compile time, so those values are already set before any execution happens. What makes the initialization int x = 22;
static is that the initializer is a constant expression.
There are cases where dynamic initialization may be hoisted to the static phase (but does not have to), but this is not one of those cases, because it does not meet the requirement that
the dynamic version of the initialization does not change the value of any other object of namespace scope prior to its initialization
When this hoisting happens, it is permissible that the resulting initial values can be different from if it didn’t happen. There’s an example in the standard for one such “indeterminate” initialization.