Boost logo

Boost :

Subject: Re: [boost] [thread] static thread_specific_ptr?
From: Sohail Somani (sohail_at_[hidden])
Date: 2009-02-26 15:55:08

Andrey Semashev wrote:
> Anthony Williams wrote:
>> The question was about a class static, which is global, and thus safe.
> Is it? If my reading of 9.4.2/7 and 3.6.2/3 is correct, static data
> members are permitted to be dynamically initialized after entering "main".

I think you are right. Pretty much only global static PODs are (must
be?) statically initialized. const local PODs can also be statically
initialized, if I remember correctly.

In some work where I was helping from afar (read: not my fault!), we had
to be sure to explicitly poke all the tss_ptrs when starting the
program. If not, we had crashes when running in multiple threads for
this reason. It was on a non-mainstream C++ platform though so I'm sure
the people who wrote that compiler interpreted the standard as was
convenient for them! This was in a much older Boost version though.

My very humble suggestion is to use a call_once based singleton or
initialize everything before starting any threads.

Sohail Somani

Boost list run by bdawes at, gregod at, cpdaniel at, john at