diff --git a/tests/fail/intrinsics/unchecked_shl2.rs b/tests/fail/intrinsics/unchecked_shl2.rs new file mode 100644 index 0000000000..a5777ebbb7 --- /dev/null +++ b/tests/fail/intrinsics/unchecked_shl2.rs @@ -0,0 +1,9 @@ +#![feature(core_intrinsics)] +use std::intrinsics; + +fn main() { + unsafe { + let _n = intrinsics::unchecked_shl(1i8, -1); + //~^ ERROR: overflowing shift by -1 in `unchecked_shl` + } +} diff --git a/tests/fail/intrinsics/unchecked_shl2.stderr b/tests/fail/intrinsics/unchecked_shl2.stderr new file mode 100644 index 0000000000..ab27c9fe91 --- /dev/null +++ b/tests/fail/intrinsics/unchecked_shl2.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: overflowing shift by -1 in `unchecked_shl` + --> $DIR/unchecked_shl2.rs:LL:CC + | +LL | let _n = intrinsics::unchecked_shl(1i8, -1); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by -1 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_shl2.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error +