View Issue Details

IDProjectCategoryView StatusLast Update
0023962FPCCompilerpublic2014-03-04 17:54
ReporterReimar Grabowski Assigned ToJonas Maebe  
PrioritynormalSeveritymajorReproducibilityalways
Status resolvedResolutionfixed 
Platformx86_64OSUbuntu 
Product Version2.7.1 
Fixed in Version2.6.4 
Summary0023962: When passing a packed record to a overridden, virtual method the method argument contains incorrect values
DescriptionWhen overriding a virtual method which takes a packed record as argument and compiling the program either with -Cr or -CR the record contains incorrect values inside the method.
Steps To Reproduceprogram 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.

Compile with either -Cr or -CR and run.

Output:
TClassB: 0.000000000E+00, 3.000000000E+00, 3.000000000E+00

Expected output:
TClassB: 0.000000000E+00, 0.000000000E+00, 3.000000000E+00
Additional InformationAlthough the method in the example code is abstract the problem stays even if the method is not abstract and only virtual.
TagsNo tags attached.
Fixed in Revision25917
FPCOldBugId
FPCTarget
Attached Files

Activities

There are no notes attached to this issue.

Issue History

Date Modified Username Field Change
2013-02-26 16:29 Reimar Grabowski New Issue
2013-03-06 13:43 Jonas Maebe Fixed in Revision => 23700
2013-03-06 13:43 Jonas Maebe Status new => resolved
2013-03-06 13:43 Jonas Maebe Fixed in Version => 2.7.1
2013-03-06 13:43 Jonas Maebe Resolution open => fixed
2013-03-06 13:43 Jonas Maebe Assigned To => Jonas Maebe
2013-11-03 15:31 Jonas Maebe Fixed in Revision 23700 => 25917
2013-11-03 15:31 Jonas Maebe Fixed in Version 2.7.1 => 2.6.3
2014-03-04 17:54 Jonas Maebe Fixed in Version 2.6.3 => 2.6.4