From: Erik Max Francis Newsgroups: comp.os.msdos.djgpp Subject: Re: printf bug ??? Date: Fri, 05 Jun 1998 18:44:34 -0700 Organization: Alcyone Systems Lines: 42 Message-ID: <35789F02.1EF059F7@alcyone.com> References: <35784F8A DOT AB5D79CC AT gpu DOT srv DOT ualberta DOT ca> NNTP-Posting-Host: charmaine.alcyone.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Shawn Hargreaves wrote: > Not true. I'm not 100% sure of the rules for argument evaluation, but > I > suspect that different compilers are allowed to do these in whatever > order they prefer. I do know for a fact that the ANSI standard > explcitly > says that the results are undefined if you use a ++ operator in a > statement that also modifies the variable in some other way. Eg. if > you > were to write something like "i += i++;", the compiler is entitled to > do > whatever the hell it likes with that statement, including nothing. The > error lies in the code, not the compiler... Correct. ANSI 6.3: Between the previous and next sequence point an object shall have its stored value modified at most once by the evaluation of an expression. Furthermore, the prior value shall be accessed only to determine the value to be stored. Note that this applies to _any_ modification of an object, not just increments or additions. Thus statements like i += i++; and *p++ = getchar(s); are undefined. "Undefined," by the ANSI standard, means that _no_ restrictions are imposed -- crashing or emailing the President of the United States is perfectly ANSI compliant. -- Erik Max Francis, &tSftDotIotE / mailto:max AT alcyone DOT com Alcyone Systems / http://www.alcyone.com/max/ San Jose, California, United States / icbm:+37.20.07/-121.53.38 \ She glanced at her watch / . . . It was 9:23. / James Clavell