View Issue Details

IDProjectCategoryView StatusLast Update
0037294FPCCompilerpublic2020-07-03 11:00
ReporterErich Eckner Assigned To 
PrioritynormalSeverityminorReproducibilityhave not tried
Status newResolutionopen 
Platformx86_64OSlinux 
Product Version3.2.0 
Summary0037294: regression in passing pointer of specialized class containing array
DescriptionThe below program works with 3.0.4, but fails with 3.2.0. Notably, the pointer to the array and the first few hundred thousand elements of the array seem to be passed fine, but at some point, the address of the element differs (and thus the content triggers all kind of strange errors).
Steps To Reproducecat >test.pas <<EOF
program test;

type
  pTCBExtended = ^tCBExtended;
  pTCBDouble = ^tCBDouble;
  tCA = class
    procedure m(c: pTCBExtended); overload;
    procedure m(c: pTCBDouble); overload;
  end;
  generic tCB<precision> = class
    ar: array of precision;
  end;
  tCBExtended = specialize tCB<extended>;
  tCBDouble = specialize tCB<double>;

procedure tCA.m(c: pTCBExtended);
begin
  writeln(c^.ar[0]);
  writeln(c^.ar[1036651]);
end;

procedure tCA.m(c: pTCBDouble);
begin
  writeln(c^.ar[0]);
  writeln(c^.ar[1036651]);
end;

var
  ca: tCA;
  cb: tCBDouble;

begin
  cb:=tCBDouble.create;
  setlength(cb.ar,1024*1024);
  cb.ar[0]:=42;
  cb.ar[1036651]:=42;
  ca:=tCA.create;
  ca.m(pTCBDouble(@cb));
  ca.free;
  cb.free;
end.
EOF
fpc -MObjFPC test.pas
./test
Additional InformationI tried to avoid to pass pointers to classes, but I could not find a way which worked with generic/specialized types. E.g. I cannot forward-declare "tCBDouble" if it is defined as "tCBDouble = specialize tCB<double>" afterwards.
TagsNo tags attached.
Fixed in Revision
FPCOldBugId
FPCTarget
Attached Files

Activities

There are no notes attached to this issue.

Issue History

Date Modified Username Field Change
2020-07-03 11:00 Erich Eckner New Issue