[Pkg-pascal-devel] Bug#895693: arm64: Incorrect record member value when returned from a function
Punit Agrawal
punitagrawal at gmail.com
Sat Apr 14 19:30:27 BST 2018
Source: fpc
Version: 3.0.4+dfsg-16
Severity: normal
Dear Maintainer,
While investigating build failure reported in #891682 I've stumbled
upon what seems like a free pascal compiler issue on arm64.
The value of a member of a record returned by a function varies
depending on usage.
The observed value of
S.Width where S := R.ScaleAround0(2)
differs from the value of
R.ScaleAround0(2).Width
The values differ on arm64 but agree on x86-64.
The attached reproducer gives the following output on arm64 -
arm64:~/src/fpc-test$ ./test
S.Width=0 R.ScaleAround0(2).Width=214748364800
while on x86-64
x86-64$ ./test
S.Width=0 R.ScaleAround0(2).Width=0
The reproducer is derived from a failing test in Castle Game Engine.
Thanks,
Punit
-------------- next part --------------
program test;
{$mode objfpc}{$H+}
{$modeSwitch advancedRecords}
type
TRectangle = record
public
Left, Bottom: Integer;
Width, Height: Cardinal;
function ScaleAround0(const Factor: Single): TRectangle;
end;
function TRectangle.ScaleAround0(const Factor: Single): TRectangle;
begin
if Width <= 0 then
begin
Result.Width := Width;
Result.Left := Left;
end else
Writeln('This should never happen');
Result.Height := Height;
Result.Bottom := Bottom;
end;
function Rectangle(const Left, Bottom: Integer;
const Width, Height: Cardinal): TRectangle;
begin
Rectangle.Left := Left;
Rectangle.Bottom := Bottom;
Rectangle.Width := Width;
Rectangle.Height := Height;
end;
var
R, S : TRectangle;
begin
R := Rectangle(10, 20, 0, 50);
S := R.ScaleAround0(2);
Writeln('S.Width=', S.Width, ' R.ScaleAround0(2).Width=', R.ScaleAround0(2).Width);
end.
More information about the Pkg-pascal-devel
mailing list