Skip to content

f32::NAN as i128 different between miri and LLVM #65245

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

Closed
bjorn3 opened this issue Oct 9, 2019 · 5 comments
Closed

f32::NAN as i128 different between miri and LLVM #65245

bjorn3 opened this issue Oct 9, 2019 · 5 comments

Comments

@bjorn3
Copy link
Member

bjorn3 commented Oct 9, 2019

fn main() {
    let f = std::f32::NAN;
    assert_eq!(f as i128, 0x7fffffffffffffffffffffffffffffffi128); // LLVM
    assert_eq!(std::f32::NAN as i128, 0i128); // miri
}
@ollie27
Copy link
Member

ollie27 commented Oct 9, 2019

Duplicate of #10184

@ollie27 ollie27 marked this as a duplicate of #10184 Oct 9, 2019
@ollie27 ollie27 closed this as completed Oct 9, 2019
@bjorn3
Copy link
Member Author

bjorn3 commented Oct 9, 2019

It doesn't seem like the LLVM case is caused by UB, as the compiler-builtins intrinsic returns 0x7fffffffffffffffffffffffffffffffi128 too.

@ollie27
Copy link
Member

ollie27 commented Oct 9, 2019

Well it definitely is UB. I don't think it's really defined anywhere what the compiler-builtins intrinsic should return in this case so what it returns doesn't really mean anything.

@bjorn3
Copy link
Member Author

bjorn3 commented Oct 9, 2019

In that case the saturating-float-casts test shouldnt test for a specific value being returned.

@ollie27
Copy link
Member

ollie27 commented Oct 9, 2019

That test needs to be compiled with -Z saturating-float-casts:

// compile-flags: -Z saturating-float-casts

See #10184 for more information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants