Path: utzoo!utgpu!water!watmath!clyde!motown!vilya!lcuxlm!whuts!att!rutgers!mit-eddie!bbn!uwmcsd1!mailrus!ncar!oddjob!mimsy!chris From: chris@mimsy.UUCP (Chris Torek) Newsgroups: comp.lang.c Subject: Re: Evaluation order of assignment. Message-ID: <13058@mimsy.UUCP> Date: 18 Aug 88 08:10:09 GMT References: <957@orion.cf.uci.edu> <13036@mimsy.UUCP> <1045@td2cad.intel.com> Distribution: na Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 30 >In article <13036@mimsy.UUCP> I noted that the expression >>> head->next = head =; is not guaranteed to produce the intended result; that instead, one must use head = ; head->next = head; or, equivalently, head = , head->next = head; In article <1045@td2cad.intel.com> brister@td2cad.intel.com (James Brister) asks: >I'm curious; Why not? In simplest terms: because the compiler is allowed to figure out where `head->next' is before bothering to do the `head = ' part. In other words, you might get what was intended, but you might instead get the equivalent of temp = head; head = ; temp->next = head; which is obviously quite different. -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163) Domain: chris@mimsy.umd.edu Path: uunet!mimsy!chris