Re: [fpc-pascal] Range checking in a for loop

2010-10-25 Thread Jonas Maebe
On 25 Oct 2010, at 13:54, Jonas Maebe wrote: On 25 Oct 2010, at 13:24, David W Noon wrote: Try declaring i : 1..3; instead, as that range matches the array's bounds. You should then get a range check at compile time. With current released versions, you won't get such a compile time e

Re: [fpc-pascal] Range checking in a for loop

2010-10-25 Thread Jonas Maebe
On 25 Oct 2010, at 13:24, David W Noon wrote: Try declaring i : 1..3; instead, as that range matches the array's bounds. You should then get a range check at compile time. With current released versions, you won't get such a compile time error. I fixed that just yesterday in svn thoug

Re: [fpc-pascal] Range checking in a for loop

2010-10-25 Thread Paul Ishenin
25.10.2010 16:06, leledumbo wrote: 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.

Re: [fpc-pascal] Range checking in a for loop

2010-10-25 Thread David W Noon
On Mon, 25 Oct 2010 01:06:16 -0700 (PDT), leledumbo wrote about [fpc-pascal] Range checking in a for loop: [snip] >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 th

[fpc-pascal] Range checking in a for loop

2010-10-25 Thread leledumbo
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