flre
flre copied to clipboard
PtrPosCharPairSearch not working with valgrind
Consider:
var s: string;
begin
s := 'ABRACA';
s += 'DABRA';
writeln(PtrPosCharPair('A', 'B', pchar(s), 11, 2));
Prints 5
as it should.
Calling the same program with valgrind, it prints -1
(PtrPosCharPairSearch returns 0)
fpc 3.2.2 on linux64, valgrind-3.16.1
When I tried to initialized the string with s := 'ABRACADABRA'
, it worked the first time even with valgrind, but now it stopped working.
It also seems to work with every other string. Like 'xABRACADABRA'
. Or
for i := 1 to 10 do begin
s := '';
s += 'ABRACA';
for j := 1 to i do s += 'A';
s += 'DABRA';
writeln(PtrPosCharPair('A', 'B', pchar(s), 11 + i, 2 ));
end;