Skip to content

Fix compile-time integer overflow when using ! on unsigned values #25527

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

Merged
merged 1 commit into from
May 18, 2015

Conversation

inrustwetrust
Copy link
Contributor

Fixes #23968.
Since the values are stored in a u64 internally, we need to be mask away the
high bits after applying the ! operator. Otherwise, these bits will be set to
one, causing overflow.

Since the values are stored in a u64 internally, we need to be mask away the
high bits after applying the ! operator. Otherwise, these bits will be set to
one, causing overflow.
@rust-highfive
Copy link
Contributor

r? @pnkfelix

(rust_highfive has picked a reviewer for you, use r? to override)

@alexcrichton
Copy link
Member

@bors: r+ d1605de

Thanks!

bors added a commit that referenced this pull request May 17, 2015
Fixes #23968.
Since the values are stored in a u64 internally, we need to be mask away the
high bits after applying the ! operator. Otherwise, these bits will be set to
one, causing overflow.
@bors
Copy link
Collaborator

bors commented May 17, 2015

⌛ Testing commit d1605de with merge 0cc99f9...

@bors bors merged commit d1605de into rust-lang:master May 18, 2015
@inrustwetrust inrustwetrust deleted the const-not-overflow branch May 18, 2015 08:47
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.

!0u32/2 gives “error: attempted to divide with overflow in a constant expression [E0020]”
5 participants