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

Unary - does not check for overflow #23154

Closed
simias opened this issue Mar 7, 2015 · 1 comment
Closed

Unary - does not check for overflow #23154

simias opened this issue Mar 7, 2015 · 1 comment

Comments

@simias
Copy link

simias commented Mar 7, 2015

The following code prints -2147483648 -2147483648:

fn main() {
    let i = 0x80000000u32 as i32;

    println!("{} {}", i, -i);
}

Both 0 - i and i / -1 generate an overflow error but it seems the unary - gladly wraps around.

@alexcrichton
Copy link
Member

I added this to the list of unimplemented overflow checks on #22020, but thanks for the report!

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

No branches or pull requests

3 participants