[cpp-threads] Yet another visibility question

Peter Dimov pdimov at mmltd.net
Wed Dec 20 02:59:44 GMT 2006


Boehm, Hans wrote:
> It might help to pin down the definition of dependence here a bit
> more. I think that once I no longer distinguish between actions that
> are performed through different control paths, this gets tricky, and
> probably impacts how useful the result is.
>
> If I have
>
> if (x.load_raw()) {
> y = 1;
> }
> y = 1;
>
> Is there a dependence?

It doesn't matter. The second store can be reordered anyway, so the compiler 
can assume that stores to y are race-free and optimize out the first store 
based on that, even if it's dependent. 




More information about the cpp-threads mailing list