-
Notifications
You must be signed in to change notification settings - Fork 66
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
Implementation of NotNan::cmp
is unsound
#150
Comments
mbrubeck
added a commit
that referenced
this issue
Jun 29, 2024
Ill-behaved FloatCore implementations for user types could have where `x.partial_cmp(&x) == None` even when `x.is_nan() == false`. This crate will now panic in those cases, rather than execute undefined behavior. Fixes #150.
mbrubeck
added a commit
that referenced
this issue
Jun 29, 2024
Ill-behaved FloatCore implementations for user types could have where `x.partial_cmp(&x) == None` even when `x.is_nan() == false`. This crate will now panic in those cases, rather than execute undefined behavior. Fixes #150.
mbrubeck
added a commit
that referenced
this issue
Jun 29, 2024
Ill-behaved FloatCore implementations for user types could have `x.partial_cmp(&x) == None` even when `x.is_nan() == false`. This crate will now panic in those cases, rather than execute undefined behavior. Fixes #150.
mbrubeck
added a commit
that referenced
this issue
Jun 29, 2024
Ill-behaved FloatCore implementations for user types could have `x.partial_cmp(&x) == None` even when `x.is_nan() == false`. This crate will now panic in those cases, rather than execute undefined behavior. Fixes #150.
mbrubeck
added a commit
that referenced
this issue
Jun 29, 2024
Ill-behaved FloatCore implementations for user types could have `x.partial_cmp(&x) == None` even when `x.is_nan() == false`. This crate will now panic in those cases, rather than execute undefined behavior. Fixes #150.
mbrubeck
added a commit
that referenced
this issue
Jun 29, 2024
Ill-behaved FloatCore implementations for user types could have `x.partial_cmp(&x) == None` even when `x.is_nan() == false`. This crate will now panic in those cases, rather than execute undefined behavior. Fixes #150.
Thanks! This is fixed in version 4.2.1. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The current implementation of
Ord
forNotNan<T>
is as follows:and the implementation of
NotNan::<T>::new
is:this makes it possible to invoke undefined behaviour without using
unsafe
with the following code:Full test case: https://gist.github.com/Earthcomputer/27d11c9c70c1335ae29cdf187362c4dd
Miri run:
The text was updated successfully, but these errors were encountered: