Am 26.06.2016 12:10 schrieb "Jürgen Hestermann" <juergen.hesterm...@gmx.de>: > > Am 2016-06-26 um 01:19 schrieb Karoly Balogh (Charlie/SGR): > > No. Local variables are not initialized by default. Managed type or not, > > doesn't make a difference. > > This is not true. > Local variables of managed types are of course initialized! > If you declare > > var S : String; > > then it is of course initialized to nil. > Otherwise the (random) pointer stored in S would be used > to change the reference counter when you assign: > > S := ''; > > The only exception (at least since FPC 3) is the function result > which is totally unexpected. > Why such an exception? > > And it is not even documented (at least not within FPC)! > Which I find a bit strange because it is very important to know. > Omitting such information in the documentation is not good. > Here > http://www.freepascal.org/docs-html/ref/refsu15.html > it says: > > "When declaring a variable of a dynamic array type, the initial length of the array is zero." > > but no word about that this is not true when this array is a the result of a function.
But also no word that it is true either, cause you're not declaring a variable for the Result. Regards, Sven
_______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal