News for hackers. Stuff that matters.
Re:Why volatile is hard to specify and implement by caf on Sunday April 10, 2016 @09:25PM (#11469084)
The example saying:

This means that the compiler is allowed to optimize

  volatile int *p = somevalue;
  int s = *p + *p;
as if it said

  volatile int *p = somevalue;
  int tmp = *p;
  int s = tmp + tmp;
is incorrect. The clause about sequence points starts with "Futhermore, " so it is an additional restriction, and to boot it only talks about stores to the volatile-qualified object, not loads, so it is entirely inapplicable to this example.

The prior clause saying "Therefore any expression referring to such an object shall be evaluated strictly according to the rules of the abstract machine, as described in 5.1.2.3." applies, and the rules of the abstract machine for the binary + operator are that each operand is evaluated (in an unspecified order). So both dereferences must be evaluated.

Re:Why volatile is hard to specify and implement by vrfcodf on Monday April 11, 2016 @07:17AM (#11470768)
I agree, I think this part makes it clear: except as modified by the unknown factors mentioned previously.

Although this is quite contradicting:

5.1.2.3. p4: In the abstract machine, all expressions are evaluated as specified by the semantics. An actual implementation need not evaluate part of an expression if it can deduce that its value is not used and that no needed side effects are produced (including any caused by calling a function or accessing a volatile object)