Skip to content

Commit 8bd620f

Browse files
committed
Auto merge of rust-lang#146 - rust-lang-nursery:gh145, r=alexcrichton
fix infinite recursion in divmoddi4 / mulodi4 on ARMv7-M processors, divmoddi4 was calling mulodi4 and mulodi4 was calling divmoddi4 leading to infinite recursion. This commit breaks the cycle by using wrapping multiplication in divmoddi4. fixes rust-lang#145 r? @alexcrichton
2 parents 0507842 + 644a1c9 commit 8bd620f

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/int/sdiv.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ macro_rules! divmod {
5555
#[cfg(all(feature = "c", any(target_arch = "x86")))]
5656
() => unsafe { $div(a, b) },
5757
};
58-
*rem = a - (r * b);
58+
// NOTE won't overflow because it's using the result from the
59+
// previous division
60+
*rem = a - r.wrapping_mul(b);
5961
r
6062
}
6163
}

0 commit comments

Comments
 (0)