Google Groups

Re: [chromium-dev] Re: eliminating static initializers


Mark Mentovai Sep 1, 2011 7:46 AM
Posted in group: Chromium-dev
Sigurður Ásgeirsson wrote:
> Initialization of function local static members MUST be deferred until first
> invocation of the containing function per the C++ specification. This does
> therefore not create a static initializer that runs at program start.
> Please note however, that the C++ runtime does not make the initialization
> threadsafe on any compiler/CRT that I'm aware of, so unless the containing
> function is only used from one thread (or under an external lock), the
> initialization is racy.

GCC (and Clang) do thread-safe initialization unless defeated with
-fno-threadsafe-statics.

Chrome does specify -fno-threadsafe-statics.