Skip to content

Commit 09145e6

Browse files
committed
Auto merge of rust-lang#152 - rust-lang-nursery:gh151, r=alexcrichton
fix debug assertion in modsi3 / moddi3 fixes rust-lang#151 this fix is very similar to rust-lang#149 r? @alexcrichton
2 parents 9681358 + 2faec6a commit 09145e6

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/int/sdiv.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,10 @@ macro_rules! mod_ {
3333
#[cfg_attr(not(test), no_mangle)]
3434
pub extern "C" fn $intrinsic(a: $ty, b: $ty) -> $tyret {
3535
let s = b >> (<$ty>::bits() - 1);
36-
let b = (b ^ s) - s;
36+
// NOTE(wrapping_sub) see comment in the `div` macro
37+
let b = (b ^ s).wrapping_sub(s);
3738
let s = a >> (<$ty>::bits() - 1);
38-
let a = (a ^ s) - s;
39+
let a = (a ^ s).wrapping_sub(s);
3940

4041
let r = urem!(a as $uty, b as $uty);
4142
($conv)((r as $ty ^ s) - s)

0 commit comments

Comments
 (0)