Skip to content

Operation resulting in a NaN gets optimized away, changing the result to infinity. #704

Open
@FractalFir

Description

@FractalFir

This is, once again, an ARM-specific bug.

When this code is compiled with LLVM(or release GCC on x86_64, or debug GCC on ARM), it prints NaN.

When the same code is compiled with release GCC on ARM, it produces an infinity value instead.

#[no_mangle]
#[inline(never)]
fn dump_var(val3: f32) {
    println!("{val3:?}")
}
fn fn2(param: f32) {
    let inf = param * 170141170000000000000000000000000000000.0;
    let should_be_nan = inf + 0.0 - inf;
    dump_var(should_be_nan);
}
fn main() {
    fn2(3.0);
}

Subtracting infinity from ininifty ought to result in an NaN value.

Metadata

Metadata

Assignees

No one assigned

    Labels

    armIssues specific to the ARM targetbugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions