Topic: thread safety of static local dynamic inits
Author: jls@sco.com (Jonathan Schilling)
Date: 1998/10/01 Raw View
In message <6uv7ev$q5j$1@shell7.ba.best.com> Nathan Myers wrote:
>Local static constructed variables, like [corrected]
>
> X& f() { static X x; return x; } // X::X() does something
>
>are also not currently thread-safe in Egcs either, nor indeed in
>most compilers that claim to be thread-safe. You have to guard
>the initialization of these statics "manually".
Is it really true that most compilers don't generate code to protect
static local variables with dynamic initializations? I know the
SCO compiler does it (when the CC -Kthread option is on), and I know
the Watcom compiler has for several years (they circulated their design
for it within the C++ standards committee). I'd be surprised if
others didn't as well....
Jonathan Schilling SCO, Inc. jls@sco.com
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]