-
Notifications
You must be signed in to change notification settings - Fork 142
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
Failing doctests on mipsel and mips64el for FloatCore::{min,max} #151
Comments
Thank you for the very detailed report! I have a feeling that this will end up being a compiler issue, either in rustc or LLVM, since there's nothing arch-specific about this code. Strange that it doesn't depend on optimization though.
I assume this was with Debian's rustc -- can you also try it with the upstream binaries?
For the purpose of testing, you could add |
Small tip -- dbg!(other.is_nan());
if self.is_nan() {
dbg!(other);
return other;
} but you could write: if dbg!(self.is_nan()) {
return dbg!(other);
} |
That's correct, I tested with Debian's rustc. Just ran the same test with the 1.40.0 version installed through rustup. It shows the same behavior.
Will try this.
That's really good to know. I keep on being surprised how well-crafted the details in Rust are. |
I explored a bit further, and it seems that the doc example doesn't even call the |
Oh, when the Line 889 in 93ff6dc
Earlier you said:
I missed this only- (And FWIW, |
Maybe it's a manifestation of rust-lang/rust#52746? It's reproducible with plain usage of std. #[cfg(test)]
mod tests {
#[test]
fn min() {
assert_eq!(1f64.min(std::f64::NAN), 1f64);
}
#[test]
fn max() {
assert_eq!(1f64.max(std::f64::NAN), 1f64);
}
} Output:
|
Ah, if #include <cmath>
#include <iostream>
#include <limits>
using namespace std;
int main() {
double qnan = numeric_limits<double>::quiet_NaN();
cout << "fmin with qnan: " << fmin(1.0, qnan) << endl;
cout << "fmax with qnan: " << fmax(1.0, qnan) << endl;
double snan = numeric_limits<double>::signaling_NaN();
cout << "fmin with snan: " << fmin(1.0, snan) << endl;
cout << "fmax with snan: " << fmax(1.0, snan) << endl;
return 0;
}
|
The
float::FloatCore::max
andfloat::FloatCore::min
doctests fail on mipsel and mips64el when building the Debian package ofnum-traits
.I was able to reproduce the behavior on a mipsel vm with Debian unstable installed. Some investigation with added debug output shows that it occurs when calculating max or min with a
NaN
value involved. In this case, aNaN
value gets returned instead of the other value It doesn't matter whether it's the first or the second parameter that isNaN
. The error only occurs when thestd
feature is enabled. It is orthogonal to thelibm
feature as well as the build mode (release or debug). From my perception, it looks as if theif self.is_nan()
andif other.is_nan()
never evaluates totrue
, but theis_nan()
doctests succeed, so that's probably not the case.What is really strange is that even when embedding an identical trait method into the doctest, it behaves as it should. I was not able to get any debug output from inside the failing method due to the type restrictions, not having the
dbg!()
macro available inside.Example code for the modified doctest of the
min
method:A log of the failing build on Debian infrastructure:
https://buildd.debian.org/status/fetch.php?pkg=rust-num-traits&arch=mips64el&ver=0.2.11-1&stamp=1578937262&raw=0
The text was updated successfully, but these errors were encountered: