Skip to content
This repository has been archived by the owner on Mar 25, 2024. It is now read-only.

Deterministically destroy sign of NaN when converted to Number #394

Merged
merged 3 commits into from
Oct 26, 2023

Conversation

dtolnay
Copy link
Owner

@dtolnay dtolnay commented Oct 26, 2023

Previously the f32 as f64 would produce a nondeterministic sign, as I found out in rust-lang/miri#3139. This would then get leaked by as_f64() or by serialization of the Number. It doesn't make a difference when serializing to YAML, but we support serializing serde_yaml::Number to TOML and other formats, where it does.

YAML only has one NaN, so even negative NaNs serialize to .nan in YAML. It seems fine to discard the original sign in serde_yaml::Number too.

@dtolnay dtolnay merged commit 23069f2 into master Oct 26, 2023
19 checks passed
@dtolnay dtolnay deleted the numbernan branch October 26, 2023 05:20
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant