[fpc-devel] Managed Types, Undefined Bhaviour

Florian Klämpfl florian at freepascal.org
Sat Jun 30 09:25:56 CEST 2018

Am 30.06.2018 um 08:47 schrieb Sven Barth via fpc-devel:
> Willibald Krenn <Willibald.Krenn at gmx.at <mailto:Willibald.Krenn at gmx.at>> schrieb am Sa., 30. Juni 2018, 08:01:
>       TBH, I didn't know this issue existed in Delphi and I've done my share of Delphi over time. I still maintain that
>     for managed types the compiler is responsible for some minimal initialization (like it's done for records etc, no?). 
> The variables we're talking about here *are* initialized.

Maybe the term initialized is wrong and confusing. They are not initialized in the sense of having defined values as 
global variables have. Non-global managed types should not be considered as being initialized (never!, like any other 
type), this is also why the compiler warns (!) about this. They can be considered as being "setup" by the compiler.

> They contain valid values and none of the internal RTL 
> routines will crash when used with them. Everyone however expects result variables of those to be initialized to Nil and 
> that is simply *not* a guaranteed given.
> Also records only initialize their managed fields. All others are left as garbage.

Managed fields of records are "setup" ;)

More information about the fpc-devel mailing list