[cpp-threads] static locals
Peter Dimov
pdimov at mmltd.net
Tue May 31 22:54:48 BST 2005
Boehm, Hans wrote:
> I understand.
>
> But so far, having the compiler perform an initialization statically,
> when it is not required to, should be transparent to all reasonable
> code. It is detectable, but it isn't very natural to write code
> that depends on the initialization happening dynamically.
>
> In the multithreaded case, I think it will not be that unusual that
> static initialization would break the code, since the necessary
> memory ordering would no longer be enforced. If we allow static
> initialization only for constant expressions, then we might start
> to see bogus casts or other mechanisms solely to force something
> not to be a constant expression. This bothers me.
Interesting. You are referring to 3.6.2/2, I presume?
Can you come up with an example where replacing dynamic initialization that
has no side effects with static initialization breaks code? (Side effects
can't be optimized out; 3.6.2/2 isn't very clear on that but 3.7.1/2
strongly implies it, and I doubt that any compiler would do such a thing.)
More information about the cpp-threads
mailing list