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

Fixed uint overflow in floorf for negative exponents #153

Merged
merged 2 commits into from
May 2, 2019

Conversation

m1el
Copy link
Contributor

@m1el m1el commented Oct 16, 2018

floorf has a bug in extracting the exponent from bits, where intermediate calculation results are u32, but can go negative for negative exponents.

The test case is very simple: calling libm::floorf(0.5) in debug mode will panic with the following message:

'attempt to subtract with overflow', <path>/libm/src/math/floorf.rs:6:13

I took a quick look at other similar functions and couldn't find problems. It would be nice to run tests in debug mode to check if there are any other places that cause similar underflows.

@m1el m1el changed the title Fixed uint underflow in floorf for negative exponents Fixed uint overflow in floorf for negative exponents Oct 18, 2018
@alexcrichton
Copy link
Member

Thanks for the PR @m1el and sorry for the delay! Are you still interested in landing this? If so mind including a test that exercises the overflow? Other than that I think this looks good to me

@alexcrichton
Copy link
Member

Ah I went ahead and pushed up a test for this mentioned in the OP, and looks like tests are still passing, so merging! Again sorry for the delay but thank you for the PR!

@alexcrichton alexcrichton merged commit 1e551a6 into rust-lang:master May 2, 2019
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.

2 participants