Per [basic.start.dynamic]/1, a non-inline non-templated non-block variable with static storage duration has "ordered" initialization, while an inline non-templated non-block variable with static storage duration has "partially ordered" initialization.
Per [basic.start.dynamic]/3, we only have an initialization order guarantee between two non-block variables with static storage duration when:
- the first and second variables both have ordered initialization, and the definition of the first variable precedes the definition of the second variable, or
- the first variable has partially ordered initialization, the second variable has ordered initialization, and the definition of the second variable is preceded by a definition of the first variable, or
- both variables have partially ordered initialization, and every definition of the second variable is preceded by a definition of the first variable.
Therefore, if the non-inline variable is defined before the inline variable, we don't have an initialization order guarantee. We only have an initialization order guarantee when the inline variable is first. So in this code, v
can be initialized before x
, resulting in undefined behaviour.
x
would always be initialized beforeA::v
anyway, wouldn't it? – Independence