A question on volatile accesses

Doug Gwyn gwyn at smoke.brl.mil
Sun Nov 4 16:07:01 AEST 1990


In article <2388 at lupine.NCD.COM> rfg at lupine.ncd.com (Ron Guilmette) writes:
>	volatile int *ip;
>			i = *++ip;
>In other words, could the program above legally be treated as:
>	volatile int *ip;
>			i = *ip;
>			++ip;

"volatile" has nothing to do with this.

The above rewrite would be incorrect in any case.  Better would be
	volatile int *ip;
			i = ip[1];
			++ip;

The only places in the code where side effects are required to be
brought up to date (synchronized) are at sequence points, such as
at the end of the assignment statement in the original code.



More information about the Comp.std.c mailing list