[rust-dev] Integer overflow, round -2147483648

Daniel Micay danielmicay at gmail.com
Sat Jun 21 17:25:59 PDT 2014

On 21/06/14 08:16 PM, Tony Arcieri wrote:
> On Sat, Jun 21, 2014 at 4:55 PM, Benjamin Striegel
> <ben.striegel at gmail.com <mailto:ben.striegel at gmail.com>> wrote:
>     In addition, bringing up hypothetical CPU architectures with support
>     for checked arithmetic is not relevant. Rust is a language designed
>     for 2014, not for 2024.
> So why not do the safe thing by default (which future CPUs may make
> fast), and provide a secondary mechanism to get the "unsafe" fast path?

CPU support for trapping on overflow will not make it fast. Either way,
it makes every integer arithmetic operation impure and will wipe out
many optimizations.

The claim that a CPU can make this faster is conjecture until someone
explains how we can actually leverage it. Turning trapping on overflow
into unwinding on overflow is not a trivial issue and would involve
changes to LLVM's design along with potentially non-portable platform
support for handling the trapping via a signal handler and then throwing
an asynchronous exception.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <http://mail.mozilla.org/pipermail/rust-dev/attachments/20140621/1314f4aa/attachment.sig>

More information about the Rust-dev mailing list