David Schwartz < XXXX@XXXXX.COM > writes:
A single-threaded program can't tell the difference because C doesn't
have dynamic initialization or destructors. The same sentence is in
C90, so therefore applies to POSIX, which supports threads. A
multithreaded program could therefore tell the difference if the
compiler just did naive "initialization on first use" without
synchronization. Since the whole point of the question is "can I rely
on such initialization being thread-safe", the answer is "YES"
(otherwise the compiler has violated the quoted statement, even under
the as-if rule), and it doesn't matter how it achieves that.
Anthony Williams | Just Software Solutions Ltd
Custom Software Development | http://www.yqcomputer.com/
Registered in England, Company Number 5478976.
Registered Office: 15 Carrallack Mews, St Just, Cornwall, TR19 7UL