<div dir="auto"><div><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">Peter Blackman via fpc-pascal <<a href="mailto:fpc-pascal@lists.freepascal.org">fpc-pascal@lists.freepascal.org</a>> schrieb am Mi., 21. Okt. 2026, 00:45:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 20/10/2026 23:28, Sven Barth via fpc-pascal wrote:<br>
> Peter Blackman via fpc-pascal <<a href="mailto:fpc-pascal@lists.freepascal.org" target="_blank" rel="noreferrer">fpc-pascal@lists.freepascal.org</a> <mailto:<a href="mailto:fpc-pascal@lists.freepascal.org" target="_blank" rel="noreferrer">fpc-pascal@lists.freepascal.org</a>>> schrieb am Di., 20. Okt. 2026, 23:51:<br>
> <br>
>     On 19/10/2026 01:45, P Padil via fpc-pascal wrote:<br>
>      > I set a small array and the program below is ok to go out of bounds.<br>
>      ><br>
>      > —<br>
>      > program test;<br>
>      ><br>
>      > type<br>
>      >     tarr = array of array of boolean;<br>
>      ><br>
>      > var<br>
>      >    exa : tarr = ((false,false,true,true),(false,false,true,true),<br>
>      >    (true,true,false,true), (true,true,true,false));<br>
>      ><br>
>      > begin<br>
>      >    writeln(exa[0,0],', ',exa[4,4]);<br>
>      >    writeln(low(exa),', ',high(exa));<br>
>      >    writeln(low(exa[4]),', ',high(exa[4]));<br>
>      > end.<br>
>     As its a dynamic array, I would use SetLength on it,<br>
>     before assigning to its elements.<br>
> <br>
> <br>
> The array is already initialized with the initialization directly following its declaration. A SetLength() is not necessary in that case.<br>
> <br>
> Regards,<br>
> Sven<br>
> <br>
> <br>
> _______________________________________________<br>
> fpc-pascal maillist  -  <a href="mailto:fpc-pascal@lists.freepascal.org" target="_blank" rel="noreferrer">fpc-pascal@lists.freepascal.org</a><br>
> <a href="https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal" rel="noreferrer noreferrer" target="_blank">https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal</a><br>
<br>
OK, but its initialised to 4x4.<br>
0..4 is 5 I think.<br></blockquote></div></div><div dir="auto"><br></div><div dir="auto">That is indeed the case. Hadn't seen noticed that the code accesses the data at index 4. ^^'</div><div dir="auto"><br></div><div dir="auto">Regards, </div><div dir="auto">Sven </div><div dir="auto"><div class="gmail_quote gmail_quote_container"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
</blockquote></div></div></div>