private static object construction bug?

Joe Buck Joe.Buck@synopsys.com
Mon Aug 5 11:00:00 GMT 2002


> Joe Buck wrote:
> 
> > Sorry, but the version of "thread-safe" that you are asking for would
> > require substantially slower code: you appear to want thread-safe locking
> > for the creation of all objects (in your case, for the construction of
> > a static variable that is local to a function).  GCC is never going to do
> > that.  The speed penalty would be enormous.
> 
> OK, thanks, that's what I wanted to know.  I had assumed that all globals
> were constructed before main() enters, but apparently C++ is not defined
> that way for all types of globals.

But you didn't have a global, you had a static variable that is local to a
function.  The rule for such objects is different.





More information about the Gcc mailing list