-
Notifications
You must be signed in to change notification settings - Fork 13.8k
Closed
Description
I am cross-compiling for a Raspberry Pi Zero W (arm-unknown-linux-gnueabihf
), and I am experiencing a strange issue when using f64::round
, which leads to an “Illegal Instruction”. Here are some minimal examples:
- Illegal Instruction at line 4
fn main() {
let v: f64 = 0.0;
println!("works: {:?}", v);
println!("fails: {:?}", (v * 10.0).round());
}
- No Illegal Instruction
fn main() {
let v: f64 = 0.0;
println!("works: {:?}", v.round());
println!("works: {:?}", (v * 10.0).round());
}
- No Illegal Instruction
fn main() {
let v: f64 = 0.0;
println!("works: {:?}", v);
println!("works: {:?}", (v * 1.0).round());
}
Apparently, the Raspberry Pi Zero W is actually a arm-unknown-linux-gnueabi
. With arm-unknown-linux-gnueabi
, I am experiencing the same behaviour, except instead of crashing with an “Illegal Instruction” it produces NaN
.
References https://users.rust-lang.org/t/f64-round-produces-illegal-instruction-on-arm-unknown-linux-gnueabihf/30798.
Metadata
Metadata
Assignees
Labels
No labels