[rust-dev] Integer overflow, round -2147483648

Daniel Micay danielmicay at gmail.com
Mon Jun 23 14:37:24 PDT 2014

On 23/06/14 05:11 PM, Gregory Maxwell wrote:
> Calling things 'slower than java' is a little bit hyperbole with the
> actual numbers posted here. But I agree any non-trivial slowdown by
> default would adversely impact adoption, I don't consider that
> desirable.

It's really not hyperbole. Java's inner loops are only 10-30% slower
than C, so Rust with checked overflow would be slower. It already has
the issue of bounds checks and checks on the arithmetic leading up to
the bounds checks would make it even harder to hoist these out of loops.

>> I don't understand what the problem would be with my proposal to have
>> either `checked { }` or checked operators + a lint for unchecked usage.
> My /own/ desire there doesn't even want either of those things, though
> I agree they could also be useful.
> With the performance concerns aside, my reason for commenting was
> wanting the programmers intention to be well specified enough in
> widely deployed software that strong static and debug-build dynamic
> checking are able to suss out all aspects of software correctness, not
> just memory safety.
> I think it will be unfortunate if rust takes a step back from C by
> resulting in an ecosystem where common idiomatic rust code is less
> amenability to tools that help software authors find incorrect code by
> reasoning from or trapping on overflow behavior.

The need to distinguish between wrapping as a bug and wrapping as an
error case would make Rust more difficult to write. I can see the
appeal, but I don't think it's worth the cost. I think Rust is already
pushing the complexity / noise limit that people will tolerate just to
achieve memory safety without losing references as values or using a
garbage collector, so I'm generally against adding more pain for the
sake of catching regular bugs.

-------------- 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/20140623/d8aa19a7/attachment.sig>

More information about the Rust-dev mailing list