http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53785

--- Comment #2 from vincenzo Innocente <vincenzo.innocente at cern dot ch> 
2012-06-28 04:43:27 UTC ---
I think that no one can rely on the way statics are initialized to tune side
effects.
The only things to guarantee are that is guarded and, I think, that the order
is preserved (because of possible side effects). in case getId is inlined even
the order can be optimized in my opinion...

Now one can have race conditions, so getId could actually be called by
different threads in a unpredictable way. With a single gard it will become a
unique critical section (or a sort of transactional memory block).
Maybe experts in initialization in multi-threaded environments shall comment
further...

Reply via email to