Subj : Re: double-checked locking in C To : comp.programming.threads From : Giancarlo Niccolai Date : Thu Jul 07 2005 01:15 pm Laurent Deniau wrote: > David Hopwood wrote: >> You're mistaken; processors can reorder memory accesses across jumps. > > I was abusively talking of a jump while in fact the goal was to have a > call. I don't know if processor can do tentative evaluation of a call, > but the value it has to assigned is returned by value from the call. > Actually, in parallel architectures it is possible to perform tentative evaluation of calls. However, I would not suggest to rely on such idioms in C, and more notably in C++, as the compiler may even decide on its own to inline calls, or your programmers team may turn a function into a macro/inline later on, and you would end up with a bug that would be deadly difficult to track down. Please notice that I know that what I am saying here is not directly related with the efficacy of this method, but it's however worth to be considered when choosing to use this idiom instead of others. Bests, Giancarlo Niccolai. .