Actions

icon Post
text/html Subscribe
text/html Unsubscribe

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • To: Mark Mitchell <mark@xxxxxxxxxxxxxxxx>
  • Subject: Re: [c++-pthreads] Initialization of local static mutex
  • From: Roland Schwarz <roland.schwarz@xxxxxxxxx>
  • Date: Mon, 09 Oct 2006 08:15:33 +0200

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