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

Fix overflow checking in unsigned pow() #34942

Merged
merged 2 commits into from Sep 20, 2016

Conversation

Projects
None yet
5 participants
@porglezomp
Copy link
Contributor

commented Jul 20, 2016

The pow() method for unsigned integers produced 0 instead of trapping overflow for certain inputs. Calls such as 2u32.pow(1024) produced 0 when they should trap an overflow. This also adds tests for the correctly handling overflow in unsigned pow().

This was previously fixed for signed integers in #28248, but it seems unsigned integers got missed that time.

For issue number #34913

@rust-highfive

This comment has been minimized.

Copy link
Collaborator

commented Jul 20, 2016

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @aturon (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@porglezomp

This comment has been minimized.

Copy link
Contributor Author

commented Jul 20, 2016

This also brings up the problem that there's a lot of 100% duplicated code between the signed and unsigned integer implementations. This might have gotten fixed properly the first time if that duplication was reduced. Is there some reason why so much of the implementation is currently exactly duplicated between signed and unsigned integers if we're already using macros to generate the implementations within the signed/unsigned types?

@bors

This comment has been minimized.

Copy link
Contributor

commented Aug 5, 2016

☔️ The latest upstream changes (presumably #35283) made this pull request unmergeable. Please resolve the merge conflicts.

porglezomp added some commits Jul 20, 2016

Fix overflow checking in unsigned pow()
The pow() method for unsigned integers produced 0 instead of trapping
overflow for certain inputs. Calls such as 2u32.pow(1024) produced 0
when they should trap an overflow. This also adds tests for the
correctly handling overflow in unsigned pow().

For issue number #34913

@porglezomp porglezomp force-pushed the porglezomp:master branch from 2beb15f to b8c4e9c Aug 7, 2016

@porglezomp

This comment has been minimized.

Copy link
Contributor Author

commented Sep 20, 2016

This is still waiting for review, is there anything I can do on this?

@sfackler

This comment has been minimized.

Copy link
Member

commented Sep 20, 2016

Oops, sorry for missing this! Looks good to me!

@bors r+

@bors

This comment has been minimized.

Copy link
Contributor

commented Sep 20, 2016

📌 Commit b8c4e9c has been approved by sfackler

@bors

This comment has been minimized.

Copy link
Contributor

commented Sep 20, 2016

⌛️ Testing commit b8c4e9c with merge cbd84ae...

bors added a commit that referenced this pull request Sep 20, 2016

Auto merge of #34942 - porglezomp:master, r=sfackler
Fix overflow checking in unsigned pow()

The pow() method for unsigned integers produced 0 instead of trapping overflow for certain inputs. Calls such as 2u32.pow(1024) produced 0 when they should trap an overflow. This also adds tests for the correctly handling overflow in unsigned pow().

This was previously fixed for signed integers in #28248, but it seems unsigned integers got missed that time.

For issue number #34913

@bors bors merged commit b8c4e9c into rust-lang:master Sep 20, 2016

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.