Path: utzoo!attcan!uunet!husc6!rutgers!att!ihlpb!nevin1
From: nevin1@ihlpb.ATT.COM (Liber)
Newsgroups: comp.lang.c
Subject: Re: Evaluation order of assignment.
Message-ID: <8555@ihlpb.ATT.COM>
Date: 18 Aug 88 00:00:45 GMT
References: <957@orion.cf.uci.edu>
Reply-To: nevin1@ihlpb.UUCP (55528-Liber,N.J.)
Distribution: na
Organization: AT&T Bell Laboratories - Naperville, Illinois
Lines: 31

In article <957@orion.cf.uci.edu> schmidt@bonnie.ics.uci.edu (Douglas C. Schmidt) writes:

>Is the following always guaranteed to produce the "intended" result:

>[...]
>   return(head->next = head = (struct list *) malloc(sizeof(struct list)));

>Since assignment associates from right-to-left this
>will alway work, right (cryptic style notwithstanding !! ;-)).

No (you should probably get a compiler warning).  Although assignment
*associates* from right-to-left, assignment does not (necessarily)
*evaluate* from right-to-left.  All that associativity means is that

	(a) = (b) = (c);

(where a, b, c are expressions and a,b both produce lvalues) is
equivalent to

	( (a) = ( (b) = (c) ) );

and not

	( ( (a) = (b) ) = (c) );

order of evaluation of the expressions a, b, c is still undefined.
-- 
 _ __		NEVIN J. LIBER	..!att!ihlpb!nevin1	(312) 979-???? IH 4F-410
' )  )				There is something embarrassing about working at
 /  / _ , __o  ____		AT&T and not being able to get a *PHONE*! :-)
/  (_