Ensure f32 deserialized from f64 and vice versa preserve NaN sign #2637
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
f32 as f64
andf64 as f32
, if the input is NaN, produces an output NaN with nondeterministic sign. This leads to bugs like TOML+nan
and-nan
and YAML.nan
being deserialized to f32 with the wrong sign nondeterministically because they're manipulated as f64 internally by the library's Value type.See rust-lang/miri#3139.