string.compare delivers incorrect result in special cases ( pchar(nil) => string ('') => compare( 'value') results in 0 (equals) )
- Lazarus/FPC Version: Lazarus 4.0 (rev lazarus_4_0) FPC 3.2.2 x86_64-win64-win32/win64
- Operating System: Windows 11 (same in Linux Mint 22)
- CPU / Bitness: 64
Maybe it's rather an FPC issue? Where can I file it, if so?
What happens
I used string.compare and it returns 0 when it should not (from my point of view)
What did you expect
compare should return a result<> 0
Steps to reproduce
Program Example;
Uses
sysUtils;
Var
vIn1 : intEger;
vpC1 : pChar;
vSt1 : String;
Begin
vpC1:= Nil;
vSt1:= vpC1; // vSt1 is '' now
vIn1:= string.compare( vSt1, '1', [ coIgnoreCase]); // vIn1 is 0 now
// so '' should be equal to '1' => that is not correct :/
writeLn( vIn1);
End.
Edited by Maxim Ganetsky