C++ standards (earlier than C++17, at least) have said this about initialization order.
Objects with static storage duration defined in namespace scope in the same translation unit and dynamically initialized shall be initialized in the order in which their definition appears in the translation unit.
C++17 introduces inline variables, which I believe to mean that a single variable with static storage duration and namespace scope and dynamic initialization could be defined in multiple translation units.
Does C++ make any guarantees about the initialization order of these variables?
See [basic.start.dynamic] p1:
Therefore, the type of variable you are describing has "partially-ordered initialization". According to p2:
So to summarize, assuming that there are no instantiated templates in the picture:
VandWsuch thatVis defined beforeWin every translation unit, thenVis initialized beforeW.Vis inline, andWis some non-inline namespace-scope variable defined in exactly one translation unit,Vwill be initialized beforeWas long asV's definition precedesW's in that one translation unit.An intuitive way to think about initialization order is that, just as in C++14, the compiler initializes each translation unit in order, with the relative ordering of different translation units unspecified (and they can be interleaved with each other), but an inline variable with external linkage is considered to be initialized the first time the implementation "hits" one of its definitions which may be in any translation unit.
Also see p5: