Skip to content

strcmp return value changed between 8.2 alpha 1 and alpha 2 #8907

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

Closed
TRowbotham opened this issue Jul 2, 2022 · 4 comments
Closed

strcmp return value changed between 8.2 alpha 1 and alpha 2 #8907

TRowbotham opened this issue Jul 2, 2022 · 4 comments

Comments

@TRowbotham
Copy link
Contributor

Description

https://3v4l.org/Iue7N - previous behavior
https://3v4l.org/Iue7N/rfc#vgit.master - behavior in 8.2 alpha 2

I didn't notice this documented in the release notes or upgrade notes, though the return value is still technically correct according to the documentation. If the change in behavior was intentional, it may be worth noting somewhere.

PHP Version

PHP 8.2.0alpha2

Operating System

Ubuntu 20.04

@KapitanOczywisty
Copy link

Introduced in #8220 , and indeed no mention in UPGRADING

@devnexen
Copy link
Member

devnexen commented Jul 2, 2022

though the return value is still technically correct why do you think earlier versions are correct ?

@cmb69
Copy link
Member

cmb69 commented Jul 2, 2022

I think we still should document this change; after all, it broke some of our own tests, and likely breaks some userland tests as well (and maybe even production code), even though it is not really a BC break.

devnexen added a commit to devnexen/php-src that referenced this issue Jul 2, 2022
binary safe string comparisons and recent socket option addition.
@TRowbotham
Copy link
Contributor Author

though the return value is still technically correct why do you think earlier versions are correct ?

I can't say that the previous behavior is any more correct than the new behavior as they both meet the documented criteria of Returns < 0 if string1 is less than string2; > 0 if string1 is greater than string2. I just happened to have a line of code that was misusing the return value of strcmp causing a test failure in PHP 8.2 alpha 2. As @cmb69 said, its not an actual BC break, but probably still worth noting the change.

devnexen added a commit to devnexen/php-src that referenced this issue Jul 2, 2022
binary safe string comparisons and recent socket option addition.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants