-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-miriArea: The miri toolArea: The miri toolC-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
I tried this code:
fn main() {
let nan1 = f64::from_bits(0x7FF0_0001_0000_0001u64);
let nan2 = f64::from_bits(0x7FF0_0000_0000_0001u64);
assert!(nan1.is_nan());
assert!(nan2.is_nan());
let nan1_32 = nan1 as f32;
let nan2_32 = nan2 as f32;
assert!(nan1_32.is_nan());
assert!(nan2_32.is_nan());
This runs correctly (i.e. doesn't assert) when run with rust nightly, but fails at assert!(nan2_32.is_nan());
when run with miri on nightly (2020-02-20).
It seems like miri just truncated the f64 to get the f32 and therefore converted the nan2 to a floating point zero instead of a floating point NaN
Metadata
Metadata
Assignees
Labels
A-miriArea: The miri toolArea: The miri toolC-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.