On Thu, 8 Oct 2020, Bo Berglund via fpc-pascal wrote:
I would like to know if data containers of type packed record are zeroed when the item is declared? type TMyRecord = packed record AField1: byte; AField2: word; AField3: single; AField4: boolean; AField5: array[0..15] of Cardinal; end; procedure SomeProc; var myRec: TMyRecord; begin ... Will random data fill myRec until I assign each field or will the entire record be zeroed at this point?
No, as with all local unmanaged variables it contains random data. The best you can do is add this as the first line:
begin MyRec:=Default(TMyRecord); It will in effect zero out the record. Michael. _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal