<p>Am 05.10.2015 11:48 schrieb "Dennis" <<a href="mailto:dec12@avidsoft.com.hk">dec12@avidsoft.com.hk</a>>:<br>
><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 instead of a memory location?<br>
></p>
<p>The for-loop-variable contains a valid value after the loop if the loop was left using a break or goto (this does not seem to be documented in FPC's language reference guide, but AFAIK it is in Delphi; also don't know what the ISO standard says about this...).</p>
<p>Regards,<br>
Sven</p>