Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

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

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
Collaborator

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
Contributor

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
# for free to join this conversation on GitHub. Already have an account? # 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