[fpc-pascal] Class var in record breaks pointer cast

Hairy Pixels genericptr at gmail.com
Thu Feb 5 14:34:41 CET 2026


Is this a bug? Adding the class var field changes prints 0 and without it
prints 100 as expected. The class var is just a static field that isn't
actually part of the record so how could it affect the memory layout?

type
  TMyRec = record
    class var z: UInt32;
    x, y: UInt32;
  end;

var
  r: TMyRec;
  p: pointer;
begin
  r.x := 100;
  p := @r;

  writeln(PUInt32(p)^);
end.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20260205/6193e0ba/attachment.htm>


More information about the fpc-pascal mailing list