I know from previous posts on this list that function static
initialization is not thread safe. But in the case of initializing
plain old data (POD) from a re-entrant function that will return the
same value every time, the race condition appears to be
inconsequential. The assumption appears to be that POD assignment is
atomic, isn't this true on all major platforms?
For example:
unsigned int Bar(); // a threadsafe function that always returns the
same value
void Foo()
{
static unsigned int bar = Bar();
// go on to make use of bar
}
Is this assumption safe? Where is it not? Or am I just playing with
fire and asking to get burned?
Thanks,
Brian