[fpc-devel] StrPos giving a access violation

Graeme Geldenhuys graeme at mastermaths.co.za
Thu Dec 8 13:26:14 CET 2005


Hi,

The 3rd unit test fails due to StrPos giving a access violation.  I ran 
this same unit test under Delphi 7 and it passed as StrPos returned a 
nil value when passing two '' param values.

Has this been reported as a bug yet?


-----------------  CUT  -------------------
var
   lFrom: string;
   lSearch: string;
   lResult: PChar;
begin
   lFrom   := 'abc';
   lSearch := 'b';
   lResult := StrPos(Pointer(lFrom), Pointer(lSearch));
   AssertEquals('Failing on 1', 'bc', string(lResult));

   lSearch := 'x';
   lResult := StrPos(Pointer(lFrom), Pointer(lSearch));
   AssertEquals('Failing on 2', '', string(lResult));

   lFrom   := '';
   lSearch := '';
   lResult := StrPos(Pointer(lFrom), Pointer(lSearch));
   AssertEquals('Failing on 3', '', string(lResult));

-----------------  END  -------------------


Regards,
   - Graeme -









More information about the fpc-devel mailing list