I wonder if it really useful to spend the two cycles for obvious wrong input.But it is a bug, I agree to OP. Wrong input or not. When I do read the documentation (https://lazarus-ccr.sourceforge.io/docs/rtl/strutils/possetex.html) it should return 0.
DescriptionIn his example it returns a very strange result, dont you think that too?
PosSetEx returns the position in s of the first found character which is in the set c, and starts searching at character position Count. If none of the characters in c is found in s, then 0 is returned.
Errors
None.
I wonder if it really useful to spend the two cycles for obvious wrong input.But it is a bug,
I definitely didn't consider negative input logicalAlways await the unexpected :-* else we wouldn't have this thread O:-)
as it serves no purpose whatsoever.Just because I say my opinion, it is a bug, does not mean that I am not on your side, I fully agree to you that it is ill to call it that way.
If SubStr is not found or Offset is invalid (greater than the length of S or less than 1), then the result is 0.https://docwiki.embarcadero.com/Libraries/Sydney/en/System.StrUtils.PosEx
Maybe posex got fixed for some Delphi compatibility measure, but for non delphi compat routines, I think it is wiser to simply adapt the documentation.
C:\Users\Bart\LazarusProjecten\ConsoleProjecten>fpc test.pas
Free Pascal Compiler version 3.3.1 [2022/10/11] for i386
Copyright (c) 1993-2022 by Florian Klaempfl and others
Target OS: Win32 for i386
Compiling test.pas
Linking test.exe
10 lines compiled, 0.5 sec, 69808 bytes code, 4420 bytes data
C:\Users\Bart\LazarusProjecten\ConsoleProjecten>test
An unhandled exception occurred at $0040D7FF:
EAccessViolation: Access violation
$0040D7FF