[fpc-pascal] Array issue

Sven Barth pascaldragon at googlemail.com
Tue Jun 16 14:21:31 CEST 2026


Thomas Kurz via fpc-pascal <fpc-pascal at lists.freepascal.org> schrieb am
Mo., 15. Juni 2026, 11:08:

> Dear all,
>
> I'm observing a strange array issue. Please consider this code:
>
> ```
> program ArrayTest;
>
> {$MODESWITCH ARRAYOPERATORS}
>
> var x, y: packed array of PtrInt; i: Integer;
>
> begin
>   x := [0,0];
>
>   y := System.Copy (x, 0, Length(x)-2) + [234, 567] + [0, 0];
>   // prints [0,0,0,0]
>   for i := Low(y) to High(y) do writeln (y[i]);
>
>   y := System.Copy (x, 0, Length(x)-2);
>   y := y + [234, 567];
>   y := y + [0, 0];
>   // prints [234,567,0,0]
>   for i := Low(y) to High(y) do writeln (y[i]);
> end.
> ```
>
> To me, both assignments to `y` are equal in the end. But the first one
> results in `y = [0,0,0,0]`, while the second one correctly gives me `y =
> [234,567,0,0]`.
>
> I'm on Windows 64, trunk 3.3.1 (Free Pascal Compiler version 3.3.1
> [2026/03/11] for x86_64) and would appreciate if anyone could try to
> reproduce this behavior. Or explain it to me :)
>

Please report a bug.

Regards,
Sven

>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20260616/563e6478/attachment.htm>


More information about the fpc-pascal mailing list