This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: private static object construction bug?
- From: Joe Buck <Joe dot Buck at synopsys dot com>
- To: joseph dot buehler at spirentcom dot com
- Cc: Joe dot Buck at synopsys dot COM (Joe Buck), gcc at gcc dot gnu dot org
- Date: Mon, 5 Aug 2002 11:00:17 -0700 (PDT)
- Subject: Re: private static object construction bug?
> 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.