Skip to content

Incorrect sign of zero on float % #2649

Closed
@RalfJung

Description

@RalfJung

The following program works fine at runtime but panics in Miri:

fn f(one: f64) -> f64 {
    (-1.0) % one
}

fn main() {
    let black_box_one = (std::env::args().len()) as f64;
    let result_rt = f(black_box_one);
    assert!(result_rt.is_sign_negative());
}

This is basically the Miri version of rust-lang/rust#102403, leading to incorrect execution. It's similar to rust-lang/rust#100233 (likely an apfloat porting bug) but a lot harder to work around...

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-interpreterArea: affects the core interpreterI-wrongImpact: makes Miri produce incorrect program behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions