[Lazarus] Lazarus Bug: No exception raised when attempting to access an array outside of range.
Michael Van Canneyt
michael at freepascal.org
Mon May 1 09:32:08 CEST 2017
On Mon, 1 May 2017, Graham Ward via Lazarus wrote:
> Hi,
>
> Apologies if this email has been sent to the wrong location (I'm a brand
> new user to the Lazarus emailing list).
>
> Note I even tried the following line, which is obviously wrong (as the
> array has a maximum index of 71)
>
> ColIndex[175] := 500;
>
> In other languages (that I am more familiar with) an exception (Error :
> Array index outside of range) would have been raised. Why does the
> Lazarus compiler not raise a similar error?
The Free Pascal compiler does not do range checking by default, you need to
enable it with -Cr (there is an option in the project option dialog).
araminta: ~ >fpc ta.pp -Cr
araminta: ~ >./ta
Runtime error 201 at $00010D50
$00010D50
araminta: ~ >cat ta.pp
Var
I : Integer;
A : Array of byte;
B : Array of byte;
begin
SetLength(A,12);
SetLength(B,12);
for I:=0 to length(A)+1 do
A[i]:=1;
end.
Michael.
More information about the Lazarus
mailing list