Edit: Nevermind – RangeCheck was off.
Should this code create an Index out of bounds error?
type
TArrayType = TArray;
procedure TSomeClass.GetArray(var anArray: TArrayType);
begin
SetLength(anArray, 10);
for ix := 1 to 10 // Should have been 0 to 9
do anArray[ix]:= ix; // <<– Index out of bounds but no error
end;
procedure Test(SomeClassInst: TSomeClass);
var
Arr: TArray;
begin
SomeClassInst.GetArray(Arr);
// do something
end; <<– Eurekalog flags overwrite on array finalization
What are you expecting? It produces an Execption for me.
** EDIT ** With “{$RANGECHECKS ON}”
pastebin.com – [Pascal] uses SysUtils; type TArrayType = TArray; procedure GetArray – Pastebin.com
Did you check “Range checking” checkbox in compiler options ?
DOH! I assumed it was on – it was off 😛
Lars Fosdal the defaults often confuse me too as I hardly start with a fresh new program, so I tend to forget what I have changed.
Range Checking ( http://docwiki.embarcadero.com/RADStudio/Tokyo/en/Range_checking ) is defaulted as off 🙁
To me, it seems like something that should be something that is defaulted on (even if there is a performance hit – maybe on for Debug and off for Release).
https://quality.embarcadero.com/browse/RSP-16751
Turns out I already upvoted this 😛
For a reason obviously 😉
Stefan Glienke Indeed 😉
There were discussions in the pre and post Wasabi eras about this. Yada Yada Yada backward compatibity Yada Yada Yada.
I think there are RAID and QC issues for this as well that I upvoted.