[fpc-devel] Wrong docs: not initialized global variables

Michael Van Canneyt michael at freepascal.org
Thu Apr 5 17:18:27 CEST 2018

On Thu, 5 Apr 2018, Martok wrote:

> Am 05.04.2018 um 08:35 schrieb Michael Van Canneyt:
>> If the compiler devs wanted, they could initialize every string with the
>> '<undefined string>' constant,
> That is in fact the -gt option.

I doubt -gt does something for managed types?

>> Pascal states: do not assume that variables are initialized.
> Corollary: there is no guarantee that "class operator Initialize()" is ever
> called, and Maciej can roll back management operators. I very much doubt this is
> what you want to imply.

And why not ?

This is the whole problem and source of the "kludge' I referred to:

When introducing managed types, Delphi should have performed the full monty, 
and simply zero-out everything at any point.

This would eliminate in large part the need for management operators, since
you can then detect whether a type is initialized or not if so desired, and
act on it.

TMyManagedType = Record
   IsInitialized : Boolean;
   // The rest of what you actually need


More information about the fpc-devel mailing list