[fpc-pascal] Pointer question

Hairy Pixels genericptr at gmail.com
Wed Aug 9 04:59:23 CEST 2023


I just noticed this by accident and I don't understand. Why does " x := @r; " compile? I would expect it to fail like the next line where I cast to the explicit type.

type
  TMyRec = record end;
  PMyRec = ^TMyRec;
var
  x: PByte;
  r: TMyRec;
begin
  x := @r;                // works
  x := PMyRec(@r);  // fails
end

Regards,
	Ryan Joseph



More information about the fpc-pascal mailing list