Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!purdue!bu-cs!buengc!bph From: bph@buengc.BU.EDU (Blair P. Houghton) Newsgroups: comp.lang.c Subject: Re: powerful expressions Message-ID: <5040@buengc.BU.EDU> Date: 7 Dec 89 16:37:51 GMT References: <12855@cit-vax.Caltech.Edu> <24735@cup.portal.com> Reply-To: bph@buengc.bu.edu (Blair P. Houghton) Followup-To: comp.lang.c Distribution: usa Organization: Boston Univ. Col. of Eng. Lines: 29 In article <24735@cup.portal.com> Tim_N_Roberts@cup.portal.com writes: >In <12855@cit-vax.Caltech.Edu>, wen-king@cit-vax.Caltech.Edu (King Su) shares: >> ((qhead) ? (qtail = qtail->next = qnew) >> : (qtail = qhead = qnew))->next = 0; > >I am truly sorry for the order-of-evaluation flood that I am surely about >to bring down upon myself, but... > >Is this guaranteed to work? Does ANSI require a sequence point in >(qtail = qtail->next = qnew) so that it works? I have always been >hesitant to write something like that, because I felt that the compiler >could reasonably be expected to assign qnew to qtail first and thereby >screw up qtail->next. Am I fearing needlessly? Fear no more. The assignment operators group right-to-left. That is qtail->next = qnew is performed before qtail = qtail->next is performed. --Blair "K&R I, p. 191, for what that's worth..."