# Is software-checked integer division actually necessary?

**URL:** <https://discourse.julialang.org/t/is-software-checked-integer-division-actually-necessary/107226>\
**Category:** Internals & Design\
**Created:** [December 6, 2023, 4:29pm UTC](https://discourse.julialang.org/t/is-software-checked-integer-division-actually-necessary/107226 "2023-12-06T16:29:00Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![mbauman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mbauman/32/31082_2.png) [@mbauman](https://discourse.julialang.org/u/mbauman)\
**Post date:** [December 6, 2023, 5:03pm UTC](https://discourse.julialang.org/t/is-software-checked-integer-division-actually-necessary/107226/4 "2023-12-06T17:03:11Z")

</div>

Exceptions are totally a valid thing for LLVM to do with an undefined behavior. In this case, I think the Intel `divl` operation itself throws the exception and Julia’s signal handler catches it:

> <https://github.com/JuliaLang/julia/blob/856e1120a8f255e4907a05f0146a2026a6665dd4/src/signals-unix.c#L1003-L1014>

But other architectures — like my Apple M1 — may not have such signals or they may not be as efficient.

It’s also worth noting that if LLVM happens to _prove_ that you are dividing by zero, then it can aggressively exploit the fact that you’re in UB land and do all sorts of other strange things.

---

_[View the full topic](https://discourse.julialang.org/t/is-software-checked-integer-division-actually-necessary/107226)._
