<div dir="auto"><div><div class="gmail_quote"><div dir="ltr">Ondrej Pokorny <<a href="mailto:lazarus@kluug.net">lazarus@kluug.net</a>> schrieb am Sa., 24. März 2018, 20:49:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">This is not correct. Global simple variables are always initialized. At<br>
least in Delphi it is so:<br>
<a href="http://docwiki.embarcadero.com/RADStudio/Tokyo/en/Variables_(Delphi)" rel="noreferrer noreferrer" target="_blank">http://docwiki.embarcadero.com/RADStudio/Tokyo/en/Variables_(Delphi)</a> "If<br>
you do not explicitly initialize a global variable, the compiler<br>
initializes it to 0."<br></blockquote></div></div><div dir="auto"><br></div><div dir="auto">So, Delphi *does* document it. Okay, in that case the documentation needs to be updated, cause up to now the assumption has been that this is an implementation detail. </div><div dir="auto"><br></div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
-----<br>
<br>
Another question about this sentence in FPC docs: "Managed types are<br>
always initialized: in general this means setting the reference count to<br>
zero, or setting the pointer value of the type to Nil."<br>
<br>
Does it mean I can assume a local string variable is always (=whenever<br>
the routine is called) initialized to ''? I.e. that TestB always returns<br>
'a'?<br></blockquote></div></div><div dir="auto"><br></div><div dir="auto">For managed types this is indeed guaranteed. Otherwise there'd be exceptions upon the first use of the variable as the RTL would assume that the value is valid. </div><div dir="auto"><br></div><div dir="auto">Regards, </div><div dir="auto">Sven </div></div>