Am 06.10.2015 08:48 schrieb "Santiago A." <s...@ciberpiula.net>: > > El 05/10/2015 a las 11:48, Dennis escribió: > > > > var i , n : integer; > > > > for i := 1 to 100 do begin > > if IntArray[i] > 100 then begin > > n := i; > > break; > > end; > > end; > > > > writeln('The '+IntToStr(i)+' item in the array > 100'); > > //can we be always sure the value i is always the same as n? > > Even when the compiler optimizes it and uses a cpu register for i > > instead of a memory location? > > I remember having read somewhere that in Pascal i value is not > guaranteed after loop, although I have never found a Pascal compiler > where i<>n. > Nevertheless, you should never rely on i value after loop. It is a bad > practice.
As written in this thread already it's guaranteed if and only if the loop had been left by break/goto. Regards, Sven
_______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal