[fpc-pascal] looks like a bug
Sven Barth
pascaldragon at googlemail.com
Wed Oct 21 14:22:05 CEST 2026
Peter Blackman via fpc-pascal <fpc-pascal at lists.freepascal.org> schrieb am
Mi., 21. Okt. 2026, 00:45:
> On 20/10/2026 23:28, Sven Barth via fpc-pascal wrote:
> > Peter Blackman via fpc-pascal <fpc-pascal at lists.freepascal.org <mailto:
> fpc-pascal at lists.freepascal.org>> schrieb am Di., 20. Okt. 2026, 23:51:
> >
> > On 19/10/2026 01:45, P Padil via fpc-pascal wrote:
> > > I set a small array and the program below is ok to go out of
> bounds.
> > >
> > > —
> > > program test;
> > >
> > > type
> > > tarr = array of array of boolean;
> > >
> > > var
> > > exa : tarr = ((false,false,true,true),(false,false,true,true),
> > > (true,true,false,true), (true,true,true,false));
> > >
> > > begin
> > > writeln(exa[0,0],', ',exa[4,4]);
> > > writeln(low(exa),', ',high(exa));
> > > writeln(low(exa[4]),', ',high(exa[4]));
> > > end.
> > As its a dynamic array, I would use SetLength on it,
> > before assigning to its elements.
> >
> >
> > The array is already initialized with the initialization directly
> following its declaration. A SetLength() is not necessary in that case.
> >
> > Regards,
> > Sven
> >
> >
> > _______________________________________________
> > fpc-pascal maillist - fpc-pascal at lists.freepascal.org
> > https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
>
> OK, but its initialised to 4x4.
> 0..4 is 5 I think.
>
That is indeed the case. Hadn't seen noticed that the code accesses the
data at index 4. ^^'
Regards,
Sven
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20261021/d6549af8/attachment.htm>
More information about the fpc-pascal
mailing list