3
{ Source provided for Free Pascal Bug Report 2911 }
4
{ Submitted by "Chris Hilder" on 2004-01-19 }
5
{ e-mail: cj.hilder@astronomyinyourhands.com }
8
{$ifdef fpc}{$Mode objfpc}{$endif}
21
ARecordWithStrings : RecordWithStrings;
23
procedure RefCount(const s : string;expect:longint);
33
then writeln('Nil string.')
36
{$if defined(ver1_0) or defined(ver1_9_4)}
39
rc:=psizeint(pchar(p)-sizeof(sizeint)*2)^;
42
rc:=psizeint(pchar(p)-sizeof(sizeint)*2)^;
44
writeln('Ref count is ',rc,' expected ',expect);
49
function FunctionResultIsRecord(a : RecordWithStrings) : RecordWithStrings;
57
ARecordWithStrings.one := onestring + twostring;
58
twostring := onestring + twostring;
59
RefCount(ARecordWithStrings.one,1);
60
{ Here we allocate a temp so refcount will be 2 }
61
ARecordWithStrings := FunctionResultIsRecord(ARecordWithStrings);
62
twostring := onestring + twostring;
63
RefCount(ARecordWithStrings.one,2);
64
{ Temp is reused, refcount should stay 2 }
65
ARecordWithStrings := FunctionResultIsRecord(ARecordWithStrings);
66
twostring := onestring + twostring;
67
RefCount(ARecordWithStrings.one,2);
68
{ Temp is reused, refcount should stay 2 }
69
ARecordWithStrings := FunctionResultIsRecord(ARecordWithStrings);
70
twostring := onestring + twostring;
71
RefCount(ARecordWithStrings.one,2);