[cpp-threads] Static member functions, member access syntax and sequenced-before
Peter Dimov
pdimov at mmltd.net
Thu Nov 24 20:06:51 GMT 2011
N.M. Maclaren wrote:
> On Nov 23 2011, Peter Dimov wrote:
> >
> >It doesn't matter that you can statically determine that the value of
> >requests[0].Waitall is Request::Waitall. The function call is sequenced
> >after requests[0], its evaluation being a part of the evaluation of
> >requests[0].Waitall, and that's that.
>
> We are still at cross-purposes, but I am clearly not going to succeed
> in explaining my question, so shall give up.
No, I think I understand your point. It's my fault you don't understand
mine.
The compiler, in a multithreaded world, is not allowed to evaluate
expressions unless given permission to do so by the standard (as opposed to
a single-threaded world, in which evaluating an expression without side
effects is undetectable).
The only thing that gives the compiler permission to evaluate requests[0] is
that requests[0].Waitall has it as a subexpression. And the evaluation of
requests[0].Waitall is specified to be sequenced before the function call of
Waitall. Either the compiler evaluates requests[0] as a part of the
evaluation of requests[0].Waitall, in which case it's sequenced before the
call, or by the as-if principle it doesn't evaluate requests[0] at all.
There is no scenario in which it's permitted to evaluate requests[0] without
it being sequenced before the function call.
More information about the cpp-threads
mailing list