Path: utzoo!utgpu!water!watmath!clyde!cbosgd!ihnp4!ptsfa!ames!nrl-cmf!ukma!gatech!udel!rochester!rutgers!im4u!ut-sally!utah-cs!utah-gr!uplherc!esunix!rushfort From: rushfort@esunix.UUCP (Kevin Rushforth) Newsgroups: comp.lang.c Subject: Re: Autoincrement question Message-ID: <618X@esunix.UUCP> Date: 21 Jan 88 00:00:00 GMT References: <548@tuvie> Organization: Evans & Sutherland, Salt Lake City, Utah Lines: 31 in article <548@tuvie>, rcvie@tuvie (ELIN Forsch.z.) says: > If there is any necessity to have the whole semantic in one *expression*, use > the comma operator, as > > bar->tmp = bar, bar++; > > This operator *guarantees* the sequential evaluation of its operands from > left to right. Not quite. While it is true that bar will be evaluated before bar++, it is bar++, not bar, that will be assigned to bar->tmp. There is no guarantee as to whether bar++ or *bar (as used in bar->tmp) will be evaluated first. In fact, this expression is identical to: bar->tmp = bar++; which was the original expression that caused the problem. Better stick to the two statement version: bar->tmp = bar; bar++; Or the following one statement version: bar->tmp = bar + 1; -- Kevin C. Rushforth Evans & Sutherland Computer Corporation UUCP Address: {ihnp4,ucbvax,decvax,allegra}!decwrl!esunix!rushfort Alternate: {bellcore,cbosgd,ulysses}!utah-cs!esunix!rushfort