From: Branko Èibej (branko.cibej_at_[hidden])
Date: 2000-06-06 09:06:10
John Maddock wrote:
> I think you're getting ahead of yourself here - imagine a simple test and
> set lock, the constructor may be out of line (in assembler), but the
> destructor would typically just set the "lock" (usually an int) to zero.
> The obvious implementation would place the destructor inline, but in this
> case there are no side effects - the compiler just sees an inline function
> that does "lock.data = 0", since the lock appears to the compiler to be
> completely unrelated to the surrounding code (it doesn't know that its
> supposed to be a lock after all), it can reorder the instructions as it
> sees fit.
No, you need an atomic operation to do "lock.data = 0", so you've
again got a function call (or inline assembly -- completely off the
rails of defined behaviour).
-- Branko Èibej <branko.cibej_at_[hidden]> HERMES SoftLab, Litijska 51, 1000 Ljubljana, Slovenia voice: (+386 1) 586 53 49 fax: (+386 1) 586 52 70
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk