Closed
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