🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: net.lang.c
Article #9179

Re: Indirect comma assigned from side effects

#9179
From: Chris Torek
Date: Thu, 21 Aug 1986 20:27
33 lines
1539 bytes
In article <792@navajo.STANFORD.EDU> rokicki@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@umcp-cs		ARPA:	chris@mimsy.umd.edu
Technical Details
Message-ID: <3047@umcp-cs.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!mnetor!seismo!umcp-cs!chris
References: <792@navajo.STANFORD.EDU>

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: arc1-ca.pugleaf.net!utzoo!mnetor!seismo!umcp-cs!chris
From: chris@umcp-cs.UUCP (Chris Torek)
Newsgroups: net.lang.c
Subject: Re: Indirect comma assigned from side effects
Message-ID: <3047@umcp-cs.UUCP>
Date: Thu, 21-Aug-86 16:27:03 EDT
Article-I.D.: umcp-cs.3047
Posted: Thu Aug 21 16:27:03 1986
Date-Received: Thu, 21-Aug-86 22:28:31 EDT
References: <792@navajo.STANFORD.EDU>
Reply-To: chris@umcp-cs.UUCP (Chris Torek)
Organization: University of Maryland, Dept. of Computer Sci.
Lines: 33