Skip to content

f64::round produces Illegal Instruction on arm-unknown-linux-gnueabihf #63098

@reitermarkus

Description

@reitermarkus

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:

  1. Illegal Instruction at line 4
fn main() {
  let v: f64 = 0.0;
  println!("works: {:?}", v);
  println!("fails: {:?}", (v * 10.0).round());
}
  1. No Illegal Instruction
fn main() {
  let v: f64 = 0.0;
  println!("works: {:?}", v.round());
  println!("works: {:?}", (v * 10.0).round());
}
  1. 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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions