volatile required?
Doug Gwyn
gwyn at smoke.BRL.MIL
Fri Sep 29 00:48:37 AEST 1989
In article <712 at Aragorn.dde.dk> ct at dde.dk (Claus Tondering) writes:
- int p=3, *q=&p;
- *q=4;
- printf("%d\n",p);
-Is it acceptable that this program prints 3 instead of 4? The variable
-p is not declared volatile, and therefore the fact that *q=4 assigns
-4 to p may be considered a side effect.
No, a correct implementation must print "4" (and a new-line).
You're confusing "volatile" with "noalias" (which is no longer
in the proposed standard). C supports aliasing via pointers.
More information about the Comp.std.c
mailing list