[fpc-devel] ref count issue with out param

Martin Frb lazarus at mfriebe.de
Sat Jun 13 21:04:00 CEST 2015

On 13/06/2015 19:55, Florian Klämpfl wrote:
>> procedure Foo1(a: AnsiString; out b: AnsiString);
>> procedure Foo2(out a: AnsiString; b: AnsiString);
>> So in Delphi it does not depend on this order. The "none out" is always nil.
> Yes. Implementation specific behavior.

Really. Then Delphi documented that this (can) break ref counting?

Because if not, then the parameters are strings, which (except for const 
param) are properly ref counted, and can not become dangling pointers.

So unless Delphi documented that "out" breaks ref counting, then I 
consider this as documented behaviour.

To clarify:
* I consider "not passing a dangling pointer in a ref counted type)" as 
documented behaviour.
* passing "nil" may well be implementation specific. It would be equally 
god if the string previously in the variable would be passed, or if the 
choice would depend on other factors (may that be surrounding code, 
optimization level, compiler settings or whatever)

More information about the fpc-devel mailing list