[c++-pthreads] Initialization of local static mutex

Roland Schwarz roland.schwarz at chello.at
Mon Oct 9 06:15:33 UTC 2006


Mark Mitchell wrote:
> Yes, I've read this.  (I've spent more than a decade working on C++ 
> compilers, the C++ standard, and C++ ABIs.)

Sorry, I did not doubt your reputation, this is why I went here to
ask this question.

> However, in practice, your code is safe.

This is what I was suspecting. But you will admit, that this is a
different thing than prove.

But if the initialization would have been done as

foo()
{
   static int bar;
}

bar would happen to be zero initialized on any conforming compiler.
(before any other initializations take place)
So zero initialization is more conservative with respect to the
standard. Isn't it?

> There are other issues around 
> thread-safe initialization of statics with a constant initializers which 
> are addressed by some C++ ABIs, but you have the simpler case of a 
> constant initializer.

Now that you have brought up this issue I am curious which "other
issues" you are refering to.

Roland




More information about the c++-pthreads mailing list