arithmetic_overflow lint not triggered for overflowing shifts in promoteds #117949
Closed
Description
opened on Nov 15, 2023
I tried this code:
format_args!("{}", 1 << 32)
I expected to see this happen:
Same output as
let a = 1 << 32;
format_args!("{}", a)
which would be
error: this arithmetic operation will overflow
--> src/main.rs:3:9
|
3 | let a = 1 << 32;
| ^^^^^^^ attempt to shift left by `32_i32`, which would overflow
|
= note: `#[deny(arithmetic_overflow)]` on by default
Instead, this happened:
The code compiles with no error, the lint is not produced.
When running it, it overflows: panics at debug mode, and gives the wrong output in release.
Meta
Tested with the current stable, nightly and beta from the playground.
I have tried finding whether this has already been reported, it seems it hasn't
Activity