Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!uunet!zephyr.ens.tek.com!tektronix!sequent!ccssrv!perry From: perry@ccssrv.UUCP (Perry Hutchison) Newsgroups: comp.lang.c Subject: Re: register variable??? Message-ID: <615@ccssrv.UUCP> Date: 13 Sep 89 01:54:50 GMT References: <30585@srcsip.UUCP> <19487@mimsy.UUCP> Reply-To: perry@ccssrv.UUCP (Perry Hutchison) Organization: Control-C Software, Inc., Beaverton, OR Lines: 21 In article <19487@mimsy.UUCP> chris@mimsy.UUCP (Chris Torek) writes: > In article <30585@srcsip.UUCP> sklee@pompeii.SRC.Honeywell.COM (Sungkee Lee) > writes: > > while (i < 4) list[i] = list[++i]; > > USE LINT!!!!! > > Sheesh. Provided he has it on his system and understands the (frequently cryptic) messages it produces. Let's answer the fellow's question: The assignment produces "undefined results" because there is no guarantee as to when "side effects" (like ++) happen. According to the definition of prefix ++, the right-hand operand of = must use the incremented value of i as the subscript; however the left-hand operand may evaluate the address into which the assignment will take place either before or after the right- hand expression stores the incremented value into i. It appears that, in this implementation, that decision is different depending on whether i is a register variable.