My recollection is that ordered initialization is only guaranteed within a translation unit. There is no guarantee that any particular translation unit has been initialized before any other, so the following was dangerous and undefined:
myClass global_var();
int main() {
return 0;
}
I'm curious about initialization lists though. What if I were to do the following:
std::array<MyClass,2> global_array = {
MyClass(),
MyClass()
};
int main() {
return 0;
}
Is the initializer list guaranteed to run after the initialization of all translation units?