I have this simple code
procedure TForm2.btn1Click(Sender: TObject);
var s : TStringList;
function compare(s : TStringList; i1, i2 : integer) : integer;
begin
result := CompareText(s[i1], s[i2]);
end;
begin
s := TStringList.Create;
try
s.add('s1');
s.add('s2');
s.add('s3');
s.CustomSort(@compare);
finally
s.free;
end;
end;
It works as expected when I compile it as 32-bit, but I get Access Violation when use 64-bit.
For 64-bit version in function compare, s = nil. i2 = some random value
;
It also works as expected even for Win64 target, if i extract compare
function outside of btn1Click
function.
Is it bug of System.Classes, is there any way to fix?