-
Notifications
You must be signed in to change notification settings - Fork 347
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 #1992 - RalfJung:sdiv, r=RalfJung
adjust for div/rem overflow being UB This is the Miri side of rust-lang/rust#94512. Just some error messages change.
- Loading branch information
Showing
5 changed files
with
21 additions
and
3 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 |
---|---|---|
@@ -1 +1 @@ | ||
f0c4da49983aa699f715caf681e3154b445fb60b | ||
45660949132222ba7ec0905649b2affd68e0e13c |
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
#![feature(core_intrinsics)] | ||
fn main() { | ||
// divison of MIN by -1 | ||
unsafe { std::intrinsics::exact_div(i64::MIN, -1); } //~ ERROR result of dividing MIN by -1 cannot be represented | ||
unsafe { std::intrinsics::exact_div(i64::MIN, -1); } //~ ERROR overflow in signed remainder (dividing MIN by -1) | ||
} |
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 @@ | ||
#![feature(platform_intrinsics, repr_simd)] | ||
|
||
extern "platform-intrinsic" { | ||
pub(crate) fn simd_div<T>(x: T, y: T) -> T; | ||
} | ||
|
||
#[repr(simd)] | ||
#[allow(non_camel_case_types)] | ||
struct i32x2(i32, i32); | ||
|
||
fn main() { unsafe { | ||
let x = i32x2(1, i32::MIN); | ||
let y = i32x2(1, -1); | ||
simd_div(x, y); //~ERROR Undefined Behavior: overflow in signed division | ||
} } |
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
#![feature(core_intrinsics)] | ||
fn main() { | ||
// MIN/-1 cannot be represented | ||
unsafe { std::intrinsics::unchecked_div(i16::MIN, -1); } //~ ERROR overflow executing `unchecked_div` | ||
unsafe { std::intrinsics::unchecked_div(i16::MIN, -1); } //~ ERROR overflow in signed division (dividing MIN by -1) | ||
} |
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