Boost logo

Boost :

From: Ben Hutchings (ben.hutchings_at_[hidden])
Date: 2004-10-01 05:33:37


Peter Dimov <pdimov_at_[hidden]> wrote:
> Alexander Terekhov wrote:
> > Peter Dimov wrote:
<snip>
> >> The observable behavior is
> >>
> >> write volatile @a 1
> >
> > nop
> >
> >> read volatile @a x
> >
> > nop
> >
> >> write volatile @a x-1
> >
> > nop
> >
> >> exit(x-1)
> >
> > push 0
> > call _exit
> >
> >>
> >> in the first case, and
> >
> > Happy now (debugger notwithstanding)?
>
> No. A conforming compiler is not allowed to do that.
>
> > C'mon, volatile is brain-dead.
>
> Nobody's arguing otherwise. ;-) But a nop it isn't.

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.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk