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
Merged

Conversation

porglezomp
Copy link
Contributor

@porglezomp porglezomp 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
Copy link
Collaborator

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
Copy link
Contributor Author

porglezomp 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
Copy link
Contributor

bors commented Aug 5, 2016

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

porglezomp and others added 2 commits August 6, 2016 20:31
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 rust-lang#34913
@porglezomp
Copy link
Contributor Author

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

@sfackler
Copy link
Member

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

@bors r+

@bors
Copy link
Contributor

bors commented Sep 20, 2016

📌 Commit b8c4e9c has been approved by sfackler

@bors
Copy link
Contributor

bors commented Sep 20, 2016

⌛ Testing commit b8c4e9c with merge cbd84ae...

bors added a commit that referenced this pull request Sep 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().

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

For issue number #34913
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.

5 participants