A different view of volatile

mikew at wyse.wyse.com mikew at wyse.wyse.com
Wed May 4 11:03:24 AEST 1988


It seems that volatile is ill-defined when combined with operators
that operate in-place.  A way of alleviating this problem would
be to state that conforming programs can't have a volatile variable
that is on boths sides of an equal sign,  volatile variables can't
be used on the left hand side of the following 
operators: +=, -=, *=, /=, |=, &=, and volatiles can't be used at all
with the following operators: ++, --.

Example:
...
volatile int a,b;
int c;

a=a;		/* illegal */
a=b;		/* legal */
a=c;		/* legal */
c=a;		/* legal */
a=a+c;		/* illegal */
a+=c;		/* illegal */
++a;		/* illegal */
...



More information about the Comp.lang.c mailing list