Skip to content
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

core: Fix undefined wrapping behavior triggered by Rust nightly (fix #579) #582

Merged
merged 2 commits into from
May 13, 2020

Conversation

Herschel
Copy link
Member

Casting floats-to-int could be treacherous in Rust, and it is currently undefined behavior on stable if the value wasn't representable in the target type. A PR just landed in nightly that defines these to saturate. This broke a few things in our code that were incorrectly relying on this undefined behavior.

Fix these methods to avoid undefined behavior and properly handle the edge cases. Fixes #579.

See:
https://doc.rust-lang.org/1.22.1/book/first-edition/casting-between-types.html#numeric-casts (old behavior)
rust-lang/rust#71269
rust-lang/rust#10184

@Herschel Herschel merged commit 081f6a5 into ruffle-rs:master May 13, 2020
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

Successfully merging this pull request may close these issues.

Wrapping is broken in rust nightlies
1 participant