[rust-dev] Integer overflow, round -2147483648

John Regehr regehr at cs.utah.edu
Mon Jun 23 11:59:12 PDT 2014


>  > Ada's approach to integer overflows is substantially similar to AIR
> Isn't Ada's response to overflow implementation-defined?

Sort of.

First, the standard seems to require a Constraint_Error when signed 
integer overflow happens.  For example, on page 47 of the ADA 2012 standard:

"For a signed integer type, the exception Constraint_Error is raised by 
the execution of an operation that cannot deliver the correct result 
because it is outside the base range of the type."

   http://www.ada-auth.org/standards/12rm/RM-Final.pdf

On the other hand, other parts of the standard provide significant 
wiggle room, giving a design that I believe is more or less equivalent 
to AIR.  The discussion here is the best that I know of:

   http://gcc.gnu.org/ml/gcc/2009-07/msg00486.html

I believe that Ada's design point is a solid one.

John Regehr


More information about the Rust-dev mailing list