You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
The Not ! operator in combination with NAN fails with OPcache enabled #15773
While identity comparison (=== and !==) can be applied to arbitrary values, the other comparison operators should only be applied to comparable values. The result of comparing incomparable values is undefined, and should not be relied upon.
That's the easy way out.
Maybe its possible to show warnings if given pattern is used.
Yeah, a warning would be less intrusive than throwing, but would also be a BC break. It seems to me that this warrants the RFC process.
Might be something for static type checkers.
A static type checker may not be able to detect all cases, especially as NaN is a float, and can be the result of a couple of operations.
changed the title [-]The Not ! opperator in componation with NAN fails with OPcache enabled[/-][+]The Not ! operator in combination with NAN fails with OPcache enabled[/+]on Jan 28, 2025
Activity
cmb69 commentedon Sep 6, 2024
This is likely due to the optimizer converting
!($a > $b)to$a <= $b.If I remember correctly, this has been reported before. Well, might have had https://bugs.php.net/bug.php?id=80701 in mind.
cmb69 commentedon Sep 6, 2024
Indeed (simplified script):
Might be wontfix, since the optimization is generally useful, and
NaNis very special anyway. Maybe PHP should throw on anyNaNcomparisons.jsiefer commentedon Sep 6, 2024
I found it super mean to debug, but I am with you on the performance optimization.
Maybe its possible to show warnings if given pattern is used. Might be something for static type checkers.... just thinking loud
cmb69 commentedon Sep 6, 2024
Well, actually
NaNis a somewhat special case of incomparable values, and the [documentation](language.operators.comparison.incomparable states:That's the easy way out.
Yeah, a warning would be less intrusive than throwing, but would also be a BC break. It seems to me that this warrants the RFC process.
A static type checker may not be able to detect all cases, especially as
NaNis a float, and can be the result of a couple of operations.[-]The Not ! opperator in componation with NAN fails with OPcache enabled[/-][+]The Not ! operator in combination with NAN fails with OPcache enabled[/+]