Consider the following program:

program test;

var
  a: array [1..3] of Integer;
  i: Integer;
begin
  for i := 1 to 4 do
    a[i] := i;
end.

The compiler will accept this code happily, despite the fact that there's an
out of bounds array index when i = 4.

Since the behavior of for loop in FPC (at least in non Delphi / TP mode) is
deterministic, it should be possible to check whether the index is out of
bounds or not. Isn't it? Or is there any situation where it's not?
-- 
View this message in context: 
http://free-pascal-general.1045716.n5.nabble.com/Range-checking-in-a-for-loop-tp3235085p3235085.html
Sent from the Free Pascal - General mailing list archive at Nabble.com.
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to