does g++ delay initializing static local variables?
Sam Varshavchik
mrsam@courier-mta.com
Wed May 11 00:07:00 GMT 2011
Brendan Miller writes:
> Say I have a C++ function like this:
>
> void my_function() {
> static int x = 0;
> }
>
> Then will initialization of x to 0 be delayed until the first call of
> the function? The ABI spec talks about that here:
> http://www.codesourcery.com/public/cxx-abi/abi.html#once-ctor
>
> I was unclear whether this only applies to objects with constructors,
> or whether it also applies to POD initialized with a constant, as
> above.
>
> In this case, I'm especially curious about g++ 4.1's implementation.
>
> Sorry if this is an overly obscure question.
Can you show an example of code where the time of initialization of PODs
would make a difference?
I can't think of any. So, it shouldn't matter.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc-help/attachments/20110511/241e56e3/attachment.sig>
More information about the Gcc-help
mailing list