Skip to content

Rust does not comply with IEEE 754 floats: arithmetic can produce signaling NaN #107247

Closed
@Muon

Description

@Muon

The compiler optimizes x * 1.0 to x, which is incorrect whenever x is a signaling NaN. IEEE 754 mandates that the result is a quiet NaN.

Example (rustc 1.66, with -C opt-level=2): https://godbolt.org/z/5qa5Go17M

This is almost certainly an LLVM bug. It's been filed over there under llvm/llvm-project#43070. I don't know which optimization pass is responsible for it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-floating-pointArea: Floating point numbers and arithmeticC-bugCategory: This is a bug.T-langRelevant to the language team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions