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 shrink_be_int bounds check #1865

Merged
merged 1 commit into from
Sep 7, 2023
Merged

Fix shrink_be_int bounds check #1865

merged 1 commit into from
Sep 7, 2023

Conversation

chipshort
Copy link
Collaborator

noticed a problem with it after rebasing #1807 onto main

The bounds check did not account for the fact that the first bit of the rest of the bytes could be different from the sign extension bits. So, for example i8::MAX as i16 + 1 would be 0000000010000000 in binary. The first 8 bits are 0, but remaining 8 bits still overflow, as 10000000 is -128

Copy link
Member

@webmaster128 webmaster128 left a comment

Choose a reason for hiding this comment

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

Not sure if I deeply understand the change. Would need some pen and paper here. But the explanation and the tests look solid to me.

@chipshort chipshort merged commit 4e5b2bf into main Sep 7, 2023
3 checks passed
@chipshort chipshort deleted the fix-shrink-be-int branch September 7, 2023 16:06
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