Skip to content

SNaN and QNaN are swapped on mipsel and mips64el compared to most other architectures #68925

@silwol

Description

@silwol

MIPS inverts the meaning of the signal/quiet bit in NaNs compared to every other platform. Rust and LLVM assume that platforms follow the standard convention, which can lead to surprising results. This issue tracks that mismatch, but it's not really actionable -- the best we can do is document this more clearly.

Original issue (likely outdated)

The following tests fail on mipsel and mips64el architectures while succeeding most others.

#[cfg(test)]
mod tests {
    #[test]
    fn min() {
        assert_eq!(1f64.min(std::f64::NAN), 1f64);
    }
    #[test]
    fn max() {
        assert_eq!(1f64.max(std::f64::NAN), 1f64);
    }
}

It succeeded on mipsel up to stable 1.36.0 rustc, and started failing in 1.37.0 and newer. I'll attempt to use cargo-bisect-rustc track down the exact nightly version that introduced the change (might take some time because it's a qemu vm that is rather slow).

#52897 (comment) was where the initial discussion started, but it seems to be worth a separate issue instead of creating noise there.

It looks as if the failing platforms have a signaling NAN (sNAN) in opposite to the succeeding ones with a quiet NAN (qNAN).

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.O-MIPSTarget: MIPS processorsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions