[fpc-devel] Question about local variables initialization

Sven Barth pascaldragon at googlemail.com
Sat Sep 20 09:39:49 CEST 2014


Am 20.09.2014 04:40 schrieb "Gennady Agranov" <gennadyagranov at gmail.com>:
>
>
> Hi,
>
> I do not have clear picture about initialization of local variables - are
they initialized to some default value or not - and is there a way to
assure that every local variable (including record types)  is set to some
default?
>
> Of course the safest approach is to assume that everything is not
initialized and filled with garbage.
>
> Is it always true? E.g. is there a way control initialization of record
variables on stack?

Local variables are not initialized, except managed variables like
interfaces, arrays and AFAIK Strings.
You can manually initialize them though like you can global variables (the
generated code is however not much different from initializing them
yourself inside the function body unlike for global variables).

Regards,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20140920/51ffb83d/attachment.html>


More information about the fpc-devel mailing list