-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't panic on invalid shift while constfolding
Fixes #9463
- Loading branch information
Showing
3 changed files
with
38 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#![deny(arithmetic_overflow, const_err)] | ||
fn main() { | ||
let _x = -1_i32 >> -1; | ||
let _y = 1u32 >> 10000000000000u32; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
error: this arithmetic operation will overflow | ||
--> $DIR/ice-9463.rs:3:14 | ||
| | ||
LL | let _x = -1_i32 >> -1; | ||
| ^^^^^^^^^^^^ attempt to shift right by `-1_i32`, which would overflow | ||
| | ||
note: the lint level is defined here | ||
--> $DIR/ice-9463.rs:1:9 | ||
| | ||
LL | #![deny(arithmetic_overflow, const_err)] | ||
| ^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: this arithmetic operation will overflow | ||
--> $DIR/ice-9463.rs:4:14 | ||
| | ||
LL | let _y = 1u32 >> 10000000000000u32; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ attempt to shift right by `1316134912_u32`, which would overflow | ||
|
||
error: literal out of range for `u32` | ||
--> $DIR/ice-9463.rs:4:22 | ||
| | ||
LL | let _y = 1u32 >> 10000000000000u32; | ||
| ^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: `#[deny(overflowing_literals)]` on by default | ||
= note: the literal `10000000000000u32` does not fit into the type `u32` whose range is `0..=4294967295` | ||
|
||
error: aborting due to 3 previous errors | ||
|