Skip to content

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

Merged
bors merged 1 commit into
rust-lang:masterfrom
inrustwetrust:const-not-overflow
May 18, 2015
Merged

Fix compile-time integer overflow when using ! on unsigned values#25527
bors merged 1 commit into
rust-lang:masterfrom
inrustwetrust:const-not-overflow

Conversation

@inrustwetrust

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

r? @pnkfelix

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

@alexcrichton

Copy link
Copy Markdown
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

bors commented May 17, 2015

Copy link
Copy Markdown
Collaborator

⌛ Testing commit d1605de with merge 0cc99f9...

@bors

bors commented May 18, 2015

Copy link
Copy Markdown
Collaborator

@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