From the Procedure Call Standard for the ARM architecture (§7.1.5):
a compiler may ignore a volatile qualification of an automatic variable whose address is never taken unless the function calls setjmp().
Is that mean that in following code:
volatile int x = 8;
if (x == 1)
{
printf("can be optimised away??");
}
The whole if
scope can be optimised out?
This just contradict the standard, for starters, volatile accesses are part of the observable behaviour and must be performed as in the abstract machine code:
§5.1.2.3:
The least requirements on a conforming implementation are:
Accesses to volatile objects are evaluated strictly according to the rules of the abstract machine.
And also §6.7.3:
An object that has volatile-qualified type may be modified in ways unknown to the implementation or have other unknown side effects. Therefore any expression referring to such an object shall be evaluated strictly according to the rules of the abstract machine
Is there a contradiction? And if so, how is it legit that a PCS contradict the C standard?