On Fri, 2007-10-05 at 22:50 -0700, Bill Dortch wrote: > I've questioned whether this was actually safe (hence the call-out in > the code), but at least one thread I read in the JMM mailing list > archives seemed to suggest that a compiler would not reorder the write > to table[index] WRT the write to e.value, which is the issue.
Have you got a link to the thread? I'm not aware of anything which would prohibit the write to table[index] being moved before the write to e.value, since the write barrier introduced by a volatile write is one-way, and the value of e at that point does not depend on e.value. However, the issue isn't only what the compiler does; writes can effectively be reordered by cache effects, as well as by the processor itself (modern processors do not execute instructions strictly in order). -mental
signature.asc
Description: This is a digitally signed message part