i.e., would the following be expected to execute correctly even in a multithreaded environment?
int dostuff(void) {
static int somevalue = 12345;
return somevalue;
}
Or is it possible for multiple threads to call this, and one call to return whatever garbage was at &somevalue before execution began?
From the C++ Standard, section 6.7:
This means that a function-level static object must be initialised by the first time the function is entered, not necessarily when the process as a whole is initialised. At this point, multiple threads may well be running.