Skip to content

[vcpkg] Correct UInt128 code 😇#10583

Merged
strega-nil merged 4 commits intomicrosoft:masterfrom
strega-nil:fix-u128
Apr 9, 2020
Merged

[vcpkg] Correct UInt128 code 😇#10583
strega-nil merged 4 commits intomicrosoft:masterfrom
strega-nil:fix-u128

Conversation

@strega-nil
Copy link
Copy Markdown
Contributor

UInt128::operator<<(x, y) should clear the bottom 64 bits of x if
y >= 64; however, we don't do this, and so we duplicate x's bottom
bits into x.top instead of moving them. Similarly, we have the
opposite problem for UInt128::operator>>. This commit fixes these
latent bugs, which we weren't hitting because the thing we use them for
never actually shifts more than 64 bits.

Fixes #10582 :)

`UInt128::operator<<(x, y)` should clear the bottom 64 bits of `x` if
`y >= 64`; however, we don't do this, and so we duplicate `x`'s bottom
bits into `x.top` instead of moving them. Similarly, we have the
opposite problem for `UInt128::operator>>`. This commit fixes these
latent bugs, which we weren't hitting because the thing we use them for
never actually shifts more than 64 bits.
Copy link
Copy Markdown

@RobertHenry6bev RobertHenry6bev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would write some unit tests too.

@JackBoosY
Copy link
Copy Markdown
Contributor

/azp run

1 similar comment
@strega-nil
Copy link
Copy Markdown
Contributor Author

/azp run

@strega-nil
Copy link
Copy Markdown
Contributor Author

Oof, getting 504s from github when trying to download the code...

@strega-nil strega-nil merged commit 47a4913 into microsoft:master Apr 9, 2020
@strega-nil strega-nil deleted the fix-u128 branch April 10, 2020 21:23
strega-nil added a commit to strega-nil/vcpkg that referenced this pull request May 5, 2021
* [vcpkg] Correct UInt128 code 😇

`UInt128::operator<<(x, y)` should clear the bottom 64 bits of `x` if
`y >= 64`; however, we don't do this, and so we duplicate `x`'s bottom
bits into `x.top` instead of moving them. Similarly, we have the
opposite problem for `UInt128::operator>>`. This commit fixes these
latent bugs, which we weren't hitting because the thing we use them for
never actually shifts more than 64 bits.
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.

Uint128 <<= not zero filling the LSW

4 participants