Closed
Description
I tried running MIRI in this code:
#![feature(core_intrinsics)]
fn main() {
let ub = unsafe { unchecked_div(i32::MAX, -1) };
// ---> Uncomment this line to see MIRI correctly finding the overflow.
// let ub = unsafe { std::intrinsics::unchecked_div(i32::MIN, -1) };
println!("{ub}");
}
unsafe fn unchecked_div(a: i32, b: i32) -> i32 {
std::intrinsics::unchecked_div(a, b)
}
I expected to see this happen: MIRI should fail with the following error:
error: Undefined Behavior: overflow in signed division (dividing MIN by -1)
Instead, this happened: No UB is detected and the program prints -2147483647
.
Meta
I ran this using playground. The version reported is:
0.1.0 (2023-06-18 2d0aa57)