Skip to content

PtrPosCharPairSearch not working with valgrind #79

Description

@benibela

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;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions