[rust-dev] Integer overflow, round -2147483648

Masklinn masklinn at masklinn.net
Sun Jun 22 14:48:13 PDT 2014

On 2014-06-22, at 23:31 , Daniel Micay <danielmicay at gmail.com> wrote:
> On 22/06/14 05:09 PM, Rick Richardson wrote:
>> Apologies if this has been suggested, but would it be possible to have a
>> compiler switch that can add runtime checks and abort on
>> overflow/underflow/carry for debugging purposes, but the default
>> behavior is no check?  IMO this would be the best of both worlds,
>> because I would assume that one would really only care about checked
>> math during testing and dev.
> You would need to build an entirely separate set of standard libraries
> with checked overflow.

From my understanding, everything would be built with checked overflow
(unless explicitly disabled/bypassed), and the overflow check could be
disabled at compile-time/.

I don't think that's a good solution, but that's what Swift's `-Ofast`
does, it completely removes a number of checks (including overflow
checking), essentially making the language unsafe but much faster.

As a side-question, were the performances of ftrapv (in clang) ever
actually tested? There were some discussion on testing the impact
in Firefox, but that ended up with GCC's ftrapv being broken and
not doing anything, and Firefox not working with clang -ftrapv.
I've not seen any numbers since, just lots of assertions that
it's far too slow to be an option.

More information about the Rust-dev mailing list