[fpc-pascal] Regression? Problem passing a packed record to a overriden, virtual, abstract method in fpc 2.7.1.
Mattias Gaertner
nc-gaertnma at netcologne.de
Mon Feb 25 22:59:26 CET 2013
On Mon, 25 Feb 2013 22:54:51 +0100
Mattias Gaertner <nc-gaertnma at netcologne.de> wrote:
> On Sun, 24 Feb 2013 23:20:23 +0100
> Reimar Grabowski <reimgrab at web.de> wrote:
>
> > 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
>
> It works under 2.6.0 and 2.6.2 (Ubuntu 64bit).
And it works under 2.7.1 rev 23661:
TClassB: 0.000000000E+00, 0.000000000E+00, 3.000000000E+00
Mattias
More information about the fpc-pascal
mailing list