Am 05.10.2015 11:48 schrieb "Dennis" <de...@avidsoft.com.hk>:
>
>
> 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?
>

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...).

Regards,
Sven
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to