delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/03/30/02:54:48

From: Erik Max Francis <max AT alcyone DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: possible bug?
Date: Sat, 29 Mar 1997 14:14:24 -0800
Organization: Alcyone Systems
Lines: 22
Message-ID: <333D9440.5B72594C@alcyone.com>
References: <333C801C DOT 112D AT pluto DOT njcc DOT com>
NNTP-Posting-Host: newton.alcyone.com
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

shearer AT pluto DOT njcc DOT com wrote:

> the following, compiled and run under djgpp(gcc272),
> with the condition of the for loop being ++i or i++,
> seems to result in the same for both cases.
> 
> such shouldn't be the case, should it?

No, it's correct.  The increment field of the for statement (e.g., the ++i
or i++) is executed after each iteration but the value is not used for
anything; only the side effects of this statement, if any, are significant.
Thus whether you choose to use postfix increment or prefix increment is
unimportant, since the evaluation of the expression is not important, just
the side effects that expression has (namely, incrementing i).

-- 
       Erik Max Francis, &tSftDotIotE / email:  max AT alcyone DOT com
                     Alcyone Systems /    web:  http://www.alcyone.com/max/
San Jose, California, United States /    icbm:  37 20 07 N  121 53 38 W
                                   \
              "I am become death, / destroyer of worlds."
                                 / J. Robert Oppenheimer (quoting legend)

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019