Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect sign of zero on float % #2649

Closed
RalfJung opened this issue Nov 5, 2022 · 2 comments · Fixed by #3094
Closed

Incorrect sign of zero on float % #2649

RalfJung opened this issue Nov 5, 2022 · 2 comments · Fixed by #3094
Labels
A-interpreter Area: affects the core interpreter I-wrong Impact: makes Miri produce incorrect program behavior

Comments

@RalfJung
Copy link
Member

RalfJung commented Nov 5, 2022

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...

@RalfJung RalfJung added A-interpreter Area: affects the core interpreter I-wrong Impact: makes Miri produce incorrect program behavior labels Nov 5, 2022
@saethlin
Copy link
Member

The program here doesn't panic anymore, and the linked issues are closed as completed by rust-lang/rust#113843 so I think we're probably fixed too?

@RalfJung
Copy link
Member Author

Ah, good point! This can be closed with a test: #3094.

@bors bors closed this as completed in 6341692 Sep 29, 2023
RalfJung pushed a commit to RalfJung/rust that referenced this issue Sep 30, 2023
RalfJung pushed a commit to RalfJung/rust that referenced this issue Oct 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-interpreter Area: affects the core interpreter I-wrong Impact: makes Miri produce incorrect program behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants