[fpc-pascal] Regression? Problem passing a packed record to a overriden, virtual, abstract method in fpc 2.7.1.
Reimar Grabowski
reimgrab at web.de
Sun Feb 24 23:20:23 CET 2013
Hi,
see the following little program:
program argumentbug;
{$MODE ObjFpc}
uses classes;
type
TVector3 = packed record
X, Y, Z: Single;
end;
TClassA = class
protected
fVector: TVector3;
public
procedure SetVector(AVector: TVector3); virtual; abstract;
end;
{ TClassB }
TClassB = class(TClassA)
public
procedure SetVector(AVector: TVector3); override;
end;
{ TClassB }
procedure TClassB.SetVector(AVector: TVector3);
begin
writeln('TClassB: ',AVector.X,',',AVector.Y,',',AVector.Z);
fVector:=AVector;
end;
var
MyVector: TVector3;
MyClassB: TClassB;
begin
MyVector.X:=0;
MyVector.Y:=0;
MyVector.Z:=3;
MyClassB:=TClassB.Create;
MyClassB.SetVector(MyVector);
end.
Obviously the expected output is 0,0,3 but in fact the output is 0,3,3.
I am sure that this used to work as my real code showing the problem is many years old.
(The problem stays even if I don't declare the method in TClassA abstract.)
OS: Ubuntu 12.10 64-Bit
Compiler: FPC 2.7.1 Rev. 23655
R.
More information about the fpc-pascal
mailing list