[cpp-threads] Static member functions, member access syntax and sequenced-before

N.M. Maclaren nmm1 at cam.ac.uk
Wed Nov 23 17:50:16 GMT 2011


This arose today in the context of MPI.  9.4 [class.static] paragraph 2
says:

    A static member s of class X may be referred to using the
    qualified-id expression X::s; it is not necessary to use the class
    member access syntax to refer to a static member. A static member
    may be referred to using the class member access syntax, in which
    case the object-expression is evaluated.

The relevant MPI construction is, in summary:

    class Request {
    static void Waitall (...);
    }

    Request requests[100];
    requests[0].Waitall(100,requests,...);

Now, is the evaluation of requests[0] sequenced-before the call to
Waitall or not?  The latter assuredly doesn't need the value.  This
isn't particularly serious for MPI, but obviously matters in general.

In particular, if it is not specified to be sequenced-before, then
a defined program can become undefined purely because a class has
'transparently' changed a non-static member function that does not
use 'this' to a static one.

If it is so specified, I can't find it, because 1.7 paragraph 15 and
1.10 paragraph 9 are in terms of value computation, and there IS no
value computation involved in the call to Waitall!  There is a value
computation, of sorts, because 9.4 paragraph 2 says so, but it is
used neither in the resolution of Waitall, nor in constructing its
argument list.


Regards,
Nick Maclaren.






More information about the cpp-threads mailing list