-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #2914 - RalfJung:unchecked_shl, r=RalfJung
add unchecked_shl test #112238 made me realize that we have a test for add,sub,mul,shr but not shl. Add the missing test. Also name the existing tests more consistently.
- Loading branch information
Showing
4 changed files
with
25 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#![feature(unchecked_math)] | ||
|
||
fn main() { | ||
unsafe { | ||
let _n = 1i8.unchecked_shl(8); | ||
//~^ ERROR: overflowing shift by 8 in `unchecked_shl` | ||
} | ||
} |
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,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 | ||
|
File renamed without changes.
4 changes: 2 additions & 2 deletions
4
...trinsics/overflowing-unchecked-rsh.stderr → ...ests/fail/intrinsics/unchecked_shr.stderr
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