[fpc-pascal] reference-counted function results not initialized to nil

Jürgen Hestermann juergen.hestermann at gmx.de
Sat Jun 25 13:17:00 CEST 2016


Am 2016-06-25 um 09:23 schrieb Maciej Izak:
 > 2016-06-25 5:19 GMT+02:00 Michalis Kamburelis <michalis.kambi at gmail.com>:
 >     They were never guaranteed to be initialized to nil.
 > Result has special logic for string, dynamic array, method pointer and variant (well documented ;) ):
 > "For a string, dynamic array, method pointer, or variant result, the effects are the same as if the function result were declared as an additional var parameter following the declared parameters. In other words, the caller passes an additional 32-bit pointer that points to a variable in which to return the function result."
 > http://docwiki.embarcadero.com/RADStudio/Berlin/en/Program_Control#Handling_Function_Results

Does that mean that we now need to read the whole documenation of Free Pascal *and* also the whole documentation of Delphi?
And what version of Delphi?
Where is this documented within Free Pascal?

This has definitely changed with Free Pascal 3 as my programs suddenly did not work anymore and I had to add Setlength() all over my code.
Before we could rely on that managed types where always initialized (well, that's the purpose of managed types, no?).
It took me quite a while to find out why my programs failed as I did not expect such a (hidden) change.




More information about the fpc-pascal mailing list