I recently became painfully aware of Fiasco 's static initialization order . I am wondering, but if the rule is that the "initialization order is undefined for translation units" is still performed for the static members in the parent class, which are needed by the static members in the child class.
For example, let's say that we have (except, for brevity, all #guards and included)
class A {
static int count;
static int register_subclass();
};
int A::count = 0;
int A::register_subclass() {
return count ++;
}
And then subclasses A
,
class B : public A {
static int id;
};
int B::id = A::register_subclass();
There are two translation units with static objects in one, depending on the static objects in the other during initialization ... it looks like it could be an instance of the static initialization order fiasco.
My question is: is it really safe?
, , , B::id
, A::count
, , ? A
, , , , , , undefined.