Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

strcmp falsely claims it returns a 0, 1 or -1 #3629

Open
ash-m opened this issue Jul 29, 2024 · 1 comment
Open

strcmp falsely claims it returns a 0, 1 or -1 #3629

ash-m opened this issue Jul 29, 2024 · 1 comment
Labels
bug Documentation contains incorrect information

Comments

@ash-m
Copy link

ash-m commented Jul 29, 2024

The docs for strcmp say:

Return Values

Returns -1 if string1 is less than string2; 1 if string1 is greater than string2, and 0 if they are equal.

Changelog

Version Description
8.2.0 This function now returns -1 or 1, where it previously returned a negative or positive integer.

Problems:

I believe the intended logic here is:

  • Attempt to calculate the spread between to strings (unpredictable for large spreads)
  • If the strings match except for trailing characters, return the difference in characters

Whatever the logic, it seems like it does not return very predicable results other than being contrasted to 0. Here are some interesting return values: https://3v4l.org/FN86s

@cmb69
Copy link
Member

cmb69 commented Jul 29, 2024

See #3223. While this has been fixed in the migration guide (but not in UPGRADING), the fix apparently missed the changelog entries.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Documentation contains incorrect information
Projects
None yet
Development

No branches or pull requests

2 participants