RE: [boost] Re: [shared_ptr] Interlocked* - possible bug?

Peter Dimov <pdimov@mmltd.net> wrote:
I think Alexander is arguing that without a clear definition of what it means for a memory access to be "observable", the fact that volatile memory accesses are "observable behaviour" doesn't prevent them from being optimised away under the as-if rule. I expect most implementations treat "observable" as "observable by a software or hardware debugger", but of course the standard doesn't and can't say that.

Peter Dimov wrote:
Yes, I understand what is observable (extensional definition). Yet the real meaning of "observable" (intensional definition) is vague (and understandably so).
Yet there is no statement of *how* the observable behaviour can be observed. Observation is outside the program and outside the standard and so practically implementation-defined. However, I do feel that Alexander's interpretation of volatile memory access is perverse. Ben.

Ben Hutchings wrote:
Oh well. There is a clear definition of "observable" in the standard. But we know that this is not the real meaning of "observable". Hence, there is no clear definition of "observable" in the standard. Therefore, a compiler is allowed to compile all programs to nops.
There is no statement of how calls to I/O library functions can be observed. Therefore, the compiler is allowed to not call them. There is no statement of how 1+2 can be verified to yield 3. Therefore, the compiler is allowed to substitute 5.

Peter, --- Peter Dimov <pdimov@mmltd.net> wrote:
I recently read the article "Double-Checked Locking, Threads, Compiler Optimizations, and More" of Scott Meyers where he touched the Sequence Points and Observable Behavior, Compiler Optimizations and Instruction Reodering. He is more convincing than Alexander; "road to the thread-safe code isn't paved with volatile". (the presentation is available from http://www.nwcpp.org/Downloads/2004/DCLP_notes.pdf) Regards Valery Salamakha _______________________________ Do you Yahoo!? Declare Yourself - Register online to vote today! http://vote.yahoo.com
participants (3)
-
Ben Hutchings
-
Peter Dimov
-
val salamakha