assignment to/from volatile execution sequence

Karl Heuer karl at haddock.ima.isc.com
Tue Mar 6 10:42:06 AEST 1990


Taking the easy question first...

In article <36669 at mips.mips.COM> lai at mips.COM (David Lai) writes:
>	a = *(b++) = c; /* will b be incremented twice? */

No.  Even if the abstract machine semantics require you to fetch back the
value from memory, the location of the object denoted by *b++ has already been
determined and should not be re-evaluated.  This is the same reason that
	*p++ += 1;
increments p only once.

>[What happens if the middle lvalue is volatile?]

Good question.  Is it intended to be the value that was stored there, or the
value that is read back?  These are equivalent for nonvolatiles, and the
Committee may have overlooked this situation.  I suggest you write the X3
Secretariat for an official interpretation.

Karl W. Z. Heuer (karl at ima.ima.isc.com or harvard!ima!karl), The Walking Lint
(I also strongly disrecommend writing any code that depends on such nuances!)



More information about the Comp.std.c mailing list