-
Notifications
You must be signed in to change notification settings - Fork 11.8k
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
[LLDB] Operators <= and >= return a wrong result when comparing with a floating point NaN in expression evaluation #85947
Comments
@llvm/issue-subscribers-lldb Author: Ilia Kuklin (kuilpd)
Operators `<=` and `>=` are defined through `operator<` ([Scalar.cpp:857](https://github.com/llvm/llvm-project/blob/7812fcf3d79ef7fe9ec6bcdfc8fd9143864956cb/lldb/source/Utility/Scalar.cpp#L857)), which in turn calls a compare function. If the compare function returns `cmpUnordered`, `operator<` return `false`, which gets negated and operators `<=` and `>=` return an incorrect value `true`.
Source file with 2 comparisons, to see the operator results from the compiler:
LLDB log:
Maybe operators |
Thanks for the report and analysis. Agreed, checking for the possibility of an unordered comparison result seems like the way to go. |
In this particular case |
Wait. Wasn't the
|
…g to a floating point NaN (llvm#108060) Implement operators `<=` and `>=` to explicitly check the comparison results to be `cmpLessThan` or `cmpEqual` instead of negating the result of `operators<`. Fixes llvm#85947
Operators
<=
and>=
are defined throughoperator<
(Scalar.cpp:857), which in turn calls a compare function. If the compare function returnscmpUnordered
,operator<
returnfalse
, which gets negated and operators<=
and>=
return an incorrect valuetrue
.Source file with 2 comparisons, to see the operator results from the compiler:
LLDB log:
Maybe operators
<=
and>=
should analyze result separately, like in APFloat.h:1240.The text was updated successfully, but these errors were encountered: