[fpc-pascal] Initialization of packed record local variables?
Michael Van Canneyt
michael at freepascal.org
Mon Jul 18 23:30:47 CEST 2016
On Mon, 18 Jul 2016, Bo Berglund wrote:
> On Mon, 18 Jul 2016 21:52:37 +0200 (CEST), Michael Van Canneyt
> <michael at freepascal.org> wrote:
>
>>> Does not the FPC compiler reserve and zero the memory area of such
>>> variables?
>>
>> No.
>
> Does thios mean that the memory is reserved but not cleared or does it
> mean that memory is not reserved at all?
the memory is reserved, but not initialized.
>
>>
>>> In any case I am using Move() to fill the variables with data from a
>>> binary buffer, maybe the compiler is not smart enough to detect this
>>> and remove the warning?
>>
>> The compiler has no way of knowing if your move statement initializes the
>> full record.
>>
> Well, if it has no way of knowing that the record is stuffed with data
> then why does it issue a notice that it seems uninitialized?
> Are there other commands it does detect as initialization of the
> variable?
not that I know of.
you need to assign it a value, you can assign it default(yourtype)
Michael.
More information about the fpc-pascal
mailing list