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

Borrowing an overflowing expression supresses arithmetic_overflow #104578

Open
Jarcho opened this issue Nov 18, 2022 · 0 comments
Open

Borrowing an overflowing expression supresses arithmetic_overflow #104578

Jarcho opened this issue Nov 18, 2022 · 0 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. C-bug Category: This is a bug. L-arithmetic_overflow Lint: arithmetic_overflow T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@Jarcho
Copy link
Contributor

Jarcho commented Nov 18, 2022

This is possibly related to #98444

I tried this code:

fn main() {
    let x = &-(-127i8 - 1);
}

I expected to see this happen:

error: this arithmetic operation will overflow
 --> src/main.rs:3:13
  |
3 |     let x = &-(-127i8 - 1);
  |              ^^^^^^^^^^^^^ attempt to negate `i8::MIN`, which would overflow
  |
  = note: `#[deny(arithmetic_overflow)]` on by default

Instead, this happened: No diagnostic

Meta

Tested on the playground 1.65 and nightly 2022-11-17

@Jarcho Jarcho added A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. A-diagnostics Area: Messages for errors, warnings, and lints C-bug Category: This is a bug. labels Nov 18, 2022
@Noratrieb Noratrieb added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Feb 24, 2023
@jieyouxu jieyouxu added the L-arithmetic_overflow Lint: arithmetic_overflow label May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. C-bug Category: This is a bug. L-arithmetic_overflow Lint: arithmetic_overflow T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants