Skip to content

Different NaN behavior with various float functions on beta-vs-stable #139487

Closed
@alexcrichton

Description

@alexcrichton

I've run across an upcoming difference in float-related functions such as floor, trunc, ceil, etc, using a beta compiler on x86_64-unknown-linux-gnu relative to the stable compiler. Bisection points to rust-lang/compiler-builtins#763 as the regression point so while it seems that changing sources for the function implementations I wanted to confirm that it's expected that a behavior change was desired here as well.

One example change is specifically this program:

fn main() {
    println!("{:#x}", f32::from_bits(0xffa00000).floor().to_bits());
}

currently prints 0xffe00000 while the beta compiler prints 0xffa00000.

This was discovered through running the WebAssembly test suite in Wasmtime using a beta/nightly compiler instead of a stable compiler, and previously some functions were "just" the_float.floor() where now we need NaN checks around them as well. Not a huge issue for us and we're happy to work around it, but I wanted to flag this behavior nonetheless to ensure it's intended.

If this is indeed an intended behavior change (which personally I think is totally fine), I'm happy to close this.

cc @tgross35 for the relevance to rust-lang/compiler-builtins#763

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-floating-pointArea: Floating point numbers and arithmeticC-discussionCategory: Discussion or questions that doesn't represent real issues.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions