add unchecked_shl test

This commit is contained in:
Ralf Jung 2023-06-03 17:03:24 +02:00
parent 507055bc50
commit e13d2380ae
4 changed files with 25 additions and 2 deletions

View File

@ -0,0 +1,8 @@
#![feature(unchecked_math)]
fn main() {
unsafe {
let _n = 1i8.unchecked_shl(8);
//~^ ERROR: overflowing shift by 8 in `unchecked_shl`
}
}

View File

@ -0,0 +1,15 @@
error: Undefined Behavior: overflowing shift by 8 in `unchecked_shl`
--> $DIR/unchecked_shl.rs:LL:CC
|
LL | let _n = 1i8.unchecked_shl(8);
| ^^^^^^^^^^^^^^^^^^^^ overflowing shift by 8 in `unchecked_shl`
|
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
= note: BACKTRACE:
= note: inside `main` at $DIR/unchecked_shl.rs:LL:CC
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
error: aborting due to previous error

View File

@ -1,5 +1,5 @@
error: Undefined Behavior: overflowing shift by 64 in `unchecked_shr`
--> $DIR/overflowing-unchecked-rsh.rs:LL:CC
--> $DIR/unchecked_shr.rs:LL:CC
|
LL | let _n = 1i64.unchecked_shr(64);
| ^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by 64 in `unchecked_shr`
@ -7,7 +7,7 @@ LL | let _n = 1i64.unchecked_shr(64);
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
= note: BACKTRACE:
= note: inside `main` at $DIR/overflowing-unchecked-rsh.rs:LL:CC
= note: inside `main` at $DIR/unchecked_shr.rs:LL:CC
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace