mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-27 22:31:21 +02:00
* refcount fixed, it is now correctly using the same temp
This commit is contained in:
parent
4c61aa26c4
commit
dc67ea9d52
@ -48,19 +48,21 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
writeln('All reference counts should be 1 for the following...');
|
|
||||||
onestring := 'one';
|
onestring := 'one';
|
||||||
twostring := 'two';
|
twostring := 'two';
|
||||||
ARecordWithStrings.one := onestring + twostring;
|
ARecordWithStrings.one := onestring + twostring;
|
||||||
twostring := onestring + twostring;
|
twostring := onestring + twostring;
|
||||||
|
RefCount(ARecordWithStrings.one,1);
|
||||||
|
{ Here we allocate a temp so refcount will be 2 }
|
||||||
|
ARecordWithStrings := FunctionResultIsRecord(ARecordWithStrings);
|
||||||
|
twostring := onestring + twostring;
|
||||||
RefCount(ARecordWithStrings.one,2);
|
RefCount(ARecordWithStrings.one,2);
|
||||||
|
{ Temp is reused, refcount should stay 2 }
|
||||||
ARecordWithStrings := FunctionResultIsRecord(ARecordWithStrings);
|
ARecordWithStrings := FunctionResultIsRecord(ARecordWithStrings);
|
||||||
twostring := onestring + twostring;
|
twostring := onestring + twostring;
|
||||||
RefCount(ARecordWithStrings.one,3);
|
RefCount(ARecordWithStrings.one,2);
|
||||||
|
{ Temp is reused, refcount should stay 2 }
|
||||||
ARecordWithStrings := FunctionResultIsRecord(ARecordWithStrings);
|
ARecordWithStrings := FunctionResultIsRecord(ARecordWithStrings);
|
||||||
twostring := onestring + twostring;
|
twostring := onestring + twostring;
|
||||||
RefCount(ARecordWithStrings.one,4);
|
RefCount(ARecordWithStrings.one,2);
|
||||||
ARecordWithStrings := FunctionResultIsRecord(ARecordWithStrings);
|
|
||||||
twostring := onestring + twostring;
|
|
||||||
RefCount(ARecordWithStrings.one,5);
|
|
||||||
end.
|
end.
|
Loading…
Reference in New Issue
Block a user