In practice on typical 64-bit machines, the MINIMIZED
mode is
reasonably efficient, and can be generally used. It also helps
to ensure compatibility with code imported from some other
compiler to GNAT.
Setting all intermediate overflows checking (CHECKED
mode)
makes sense if you want to
make sure that your code is compatible with any other possible
Ada implementation. This may be useful in ensuring portability
for code that is to be exported to some other compiler than GNAT.
The Ada standard allows the reassociation of expressions at
the same precedence level if no parentheses are present. For
example, A+B+C
parses as though it were (A+B)+C
, but
the compiler can reintepret this as A+(B+C)
, possibly
introducing or eliminating an overflow exception. The GNAT
compiler never takes advantage of this freedom, and the
expression A+B+C
will be evaluated as (A+B)+C
.
If you need the other order, you can write the parentheses
explicitly A+(B+C)
and GNAT will respect this order.
The use of ELIMINATED
mode will cause the compiler to
automatically include an appropriate arbitrary precision
integer arithmetic package. The compiler will make calls
to this package, though only in cases where it cannot be
sure that Long_Long_Integer
is sufficient to guard against
intermediate overflows. This package does not use dynamic
alllocation, but it does use the secondary stack, so an
appropriate secondary stack package must be present (this
is always true for standard full Ada, but may require
specific steps for restricted run times such as ZFP).
Although ELIMINATED
mode causes expressions to use arbitrary
precision arithmetic, avoiding overflow, the final result
must be in an appropriate range. This is true even if the
final result is of type [Long_[Long_]]Integer'Base
, which
still has the same bounds as its associated constrained
type at run-time.
Currently, the ELIMINATED
mode is only available on target
platforms for which Long_Long_Integer
is 64-bits (nearly all GNAT
platforms).