[fpc-pascal] for loop variable value reliable after loop?

Dennis dec12 at avidsoft.com.hk
Mon Oct 5 11:48:18 CEST 2015


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?

Dennis



More information about the fpc-pascal mailing list