This is a great writeup, thanks!<p>&gt;    in debug mode, arithmetic ... is checked for overflow<p>&gt;    in release mode, overflow is not checked<p>...<p>&gt; &quot;But what about performance?&quot; I hear you ask. It is true that undefined behaviour drives optimisations by allowing the compiler to make assumptions<p>Are there any targets that have instructions like integer-add-but-trap-if-overflow?  Or maybe a mode that can be switched?  It would be interesting if there could be a high-performing path to leave the check in for release mode.