Skip to content

Commit 92b6955

Browse files
committed
Auto merge of rust-lang#94512 - RalfJung:sdiv-ub, r=oli-obk
Miri/CTFE: properly treat overflow in (signed) division/rem as UB To my surprise, it looks like LLVM treats overflow of signed div/rem as UB. From what I can tell, MIR `Div`/`Rem` directly lowers to the corresponding LLVM operation, so to make that correct we also have to consider these overflows UB in the CTFE/Miri interpreter engine. r? `@oli-obk`
2 parents 7f44a75 + c45a42a commit 92b6955

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

tests/ui/modulo_one.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
error: this arithmetic operation will overflow
1+
error: this operation will panic at runtime
22
--> $DIR/modulo_one.rs:11:5
33
|
44
LL | i32::MIN % (-1); // also caught by rustc
55
| ^^^^^^^^^^^^^^^ attempt to compute the remainder of `i32::MIN % -1_i32`, which would overflow
66
|
7-
= note: `#[deny(arithmetic_overflow)]` on by default
7+
= note: `#[deny(unconditional_panic)]` on by default
88

9-
error: this arithmetic operation will overflow
9+
error: this operation will panic at runtime
1010
--> $DIR/modulo_one.rs:21:5
1111
|
1212
LL | INT_MIN % NEG_ONE; // also caught by rustc
1313
| ^^^^^^^^^^^^^^^^^ attempt to compute the remainder of `i64::MIN % -1_i64`, which would overflow
1414

15-
error: this arithmetic operation will overflow
15+
error: this operation will panic at runtime
1616
--> $DIR/modulo_one.rs:22:5
1717
|
1818
LL | INT_MIN % STATIC_NEG_ONE; // ONLY caught by rustc

0 commit comments

Comments
 (0)