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