Skip to content

Commit

Permalink
panic! -> abort
Browse files Browse the repository at this point in the history
closes #79
  • Loading branch information
Jorge Aparicio committed Oct 6, 2016
1 parent 2706d92 commit 416bf15
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/int/udiv.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use core::mem;
use core::{intrinsics, mem};
use int::{Int, LargeInt};

/// Returns `n / d`
Expand All @@ -7,7 +7,11 @@ use int::{Int, LargeInt};
pub extern "C" fn __udivsi3(n: u32, d: u32) -> u32 {
// Special cases
if d == 0 {
panic!("Division by zero");
// NOTE This should be unreachable in safe Rust because the program will panic before
// this intrinsic is called
unsafe {
intrinsics::abort()
}
}

if n == 0 {
Expand Down Expand Up @@ -129,7 +133,11 @@ pub extern "C" fn __udivmoddi4(n: u64, d: u64, rem: Option<&mut u64>) -> u64 {
// K X
// ---
// 0 0
panic!("Division by zero");
// NOTE This should be unreachable in safe Rust because the program will panic before
// this intrinsic is called
unsafe {
intrinsics::abort()
}
}

if n.low() == 0 {
Expand Down

0 comments on commit 416bf15

Please sign in to comment.