[fpc-devel] ref count issue with out param
Florian Klämpfl
florian at freepascal.org
Sat Jun 13 16:22:26 CEST 2015
Am 13.06.2015 um 14:27 schrieb Martin Frb:
> On 13/06/2015 09:31, Florian Klämpfl wrote:
>> It is similar to
>>
>> type
>> tarray = array [1..10] of longint;
>>
>> procedure p(const a1 : tarray;var a2 : tarray);
>> begin
>> a2[1]:=4321;
>> writeln(a1[1]); // surprise
>> end;
>>
>> var
>> arr : tarray;
>>
>> begin
>> arr[1]:=1234;
>> p(arr,arr);
>> end.
>>
>
> I dont see any similarity. You pass 2 pointers to the same memory. No surprise for me. But also no
> broken ref counting.
Well, similar in the meta sense: passing the same data location with a different modifier.
More information about the fpc-devel
mailing list