Mark Mitchell wrote:
Roland Schwarz wrote:
Now that you have brought up this issue I am curious which "other issues" you are refering to.void f() { static int i = g(); }Here, you cannot do the initialization statically; it must be done the first time that f() is called. So, the key question is whether the initialization is thread-safe. Does the programmer have to change that initialization to be thread-safe, using locks in f()? Or does the compiler take care of it?
I fail to see how the programmer can make the initialization thread-safe if the compiler doesn't take care of it? Lack of memory barriers could make the bool indicating that the initialization is done visible, but not the written value.
-- Jean-Marc