Indirect comma assigned from side effects

Chris Torek chris at umcp-cs.UUCP
Fri Aug 22 06:27:03 AEST 1986


In article <792 at navajo.STANFORD.EDU> rokicki at navajo.STANFORD.EDU
(Tomas Rokicki) writes:
>... For example, consider the program:
>
>	int lhs, rhs, index; int *pointers[9];
>	foo() { *( index=lhs, pointers[index] ) = sideeffects(); }
>
>The question is, does C allow for the possibility that the order
>of evaluation might be "index=lhs" then "sideeffects()" then
>"*pointers[index]=<result>"?

No.  The compiler can, however, effectively generate either of the
following:

	temp = sideeffects();
	index = lhs;
	*pointers[index] = temp;

or

	index = lhs;
	tempp = pointers[index];
	*tempp = sideeffects();

>... On the other hand, if C does not allow the compiler to
>generate such code, then the statement is well defined.

Not really, since one sequence sets index=lhs before the call, and
the other after.
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1516)
UUCP:	seismo!umcp-cs!chris
CSNet:	chris at umcp-cs		ARPA:	chris at mimsy.umd.edu



More information about the Comp.lang.c mailing list