-
Notifications
You must be signed in to change notification settings - Fork 130
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
cast_float_to_int_edge_cases
fails on Debian / mips & mipsel
#239
Comments
I don't remember why I put that "{.0}" precision limit in the format string, but unrestricted it looks like this on i686:
The expectation is that the first "vs." should truncate and cast to I'm guessing this is a compiler codegen issue for mips, either in rustc or llvm, but I don't have the means to test mips myself. There's nothing arch-specific about this code though, and it works on other 32-bit targets. |
Within Debian, I have access to mips machine. I can do some testing for you if you want :) |
I got it working under qemu, although I used static musl, but I don't think libc matters here. It works fine for me on both mips and mipsel, using both rustup stable and 1.59 (like your debian rustc). Can you try on your system with upstream rustc? Here's an extracted test program you can try as well: #[cfg(not(target_pointer_width = "32"))]
compile_error!("this test is 32-bit only");
const MIN_M1: f64 = isize::MIN as f64 - 1.0;
const MAX_P1: f64 = isize::MAX as f64 + 1.0;
fn cast(x: f64) -> Option<isize> {
if x > MIN_M1 && x < MAX_P1 {
Some(unsafe { x.to_int_unchecked() })
} else {
None
}
}
fn main() {
dbg!(MIN_M1, MAX_P1);
for (x, expected) in [
(-2147483649.0, None),
(-2147483648.9999995, Some(isize::MIN)),
(2147483647.9999998, Some(isize::MAX)),
(2147483648.0, None),
] {
let i = cast(x);
dbg!(x, i);
assert_eq!(i, expected);
}
} |
Full log:
https://buildd.debian.org/status/fetch.php?pkg=rust-num-traits&arch=mipsel&ver=0.2.15-1&stamp=1654173339&raw=0
Can be found on:
https://buildd.debian.org/status/package.php?p=rust-num-traits&suite=sid
Different from:
#151
The text was updated successfully, but these errors were encountered: