Skip to content

Out of range float casts miscompilation #635

@bjorn3

Description

@bjorn3

I tried this code:

pub fn foo() -> f32 {
    0xffff_ffff_ffff_ffff_ffff_ffff_ffff_ffffu128 as f32
}

I expected to see this happen: Saturating to f32::INFINITY

Instead, this happened: 9223372000000000000.0 is returned

Another case is

pub fn foo() -> f32 {
    1<an absolutely huge amount of zeros>u128 as f32
}

which should give an out of range error, but returns 0.0.

Meta

  • What version of Rust GCC were you using, git sha if possible: The current version at godbolt.

Metadata

Metadata

Assignees

No one assigned

    Labels

    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