Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program SizeAffectsConstPassing;
- {$APPTYPE CONSOLE}
- type
- PSmallRec = ^TSmallRec;
- TSmallRec = record
- x: NativeInt;
- end;
- PLargeRec = ^TLargeRec;
- TLargeRec = record
- x, y: NativeInt;
- end;
- PSmallArray = ^TSmallArray;
- TSmallArray = packed array[0..3] of Byte;
- procedure TestSmallRecord(const rec: TSmallRec);
- begin
- PSmallRec(@rec)^.x := rec.x * 10;
- end;
- procedure TestLargeRecord(const rec: TLargeRec);
- begin
- PLargeRec(@rec)^.x := rec.x * 10;
- PLargeRec(@rec)^.y := rec.y * 10;
- end;
- procedure TestSmallArray(const arr: TSmallArray);
- begin
- PSmallArray(@arr)^[0] := arr[0] * 100;
- end;
- var
- s: TSmallRec;
- l: TLargeRec;
- a: TSmallArray = (1, 2, 3, 4);
- begin
- s.x := 1;
- l.x := 2;
- l.y := 3;
- TestSmallRecord(s);
- TestLargeRecord(l);
- TestSmallArray(a);
- Writeln(s.x);
- Writeln(l.x);
- Writeln(l.y);
- Writeln(a[0]);
- Writeln(a[1]);
- Writeln(a[2]);
- Writeln(a[3]);
- Readln;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement