The desired mode of for handling intermediate overflow can be specified using
Overflow_Mode pragma or an equivalent compiler switch.
The pragma has the form
pragma Overflow_Mode ([General =>] MODE [, [Assertions =>] MODE]);
MODE is one of
STRICT: intermediate overflows checked (using base type)
MINIMIZED: minimize intermediate overflows
ELIMINATED: eliminate intermediate overflows
The case is ignored, so
minimized all have the same effect.
If only the
General parameter is present, then the given
to expressions both within and outside assertions. If both arguments
are present, then
General applies to expressions outside assertions,
Assertions applies to expressions within assertions. For example:
pragma Overflow_Mode (General => Minimized, Assertions => Eliminated);
specifies that general expressions outside assertions be evaluated in “minimize intermediate overflows” mode, and expressions within assertions be evaluated in “eliminate intermediate overflows” mode. This is often a reasonable choice, avoiding excessive overhead outside assertions, but assuring a high degree of portability when importing code from another compiler, while incurring the extra overhead for assertion expressions to ensure that the behavior at run time matches the expected mathematical behavior.
Overflow_Mode pragma has the same scoping and placement
rules as pragma
Suppress, so it can occur either as a
configuration pragma, specifying a default for the whole
program, or in a declarative scope, where it applies to the
remaining declarations and statements in that scope.
Note that pragma
Overflow_Mode does not affect whether
overflow checks are enabled or suppressed. It only controls the
method used to compute intermediate values. To control whether
overflow checking is enabled or suppressed, use pragma
Unsuppress in the usual manner
Additionally, a compiler switch -gnato? or -gnato??
can be used to control the checking mode default (which can be subsequently
overridden using pragmas).
?' is one of the digits `
1' through `
1: use base type for intermediate operations (
2: minimize intermediate overflows (
3: eliminate intermediate overflows (
As with the pragma, if only one digit appears then it applies to all cases; if two digits are given, then the first applies outside assertions, and the second within assertions. Thus the equivalent of the example pragma above would be -gnato23.
If no digits follow the -gnato, then it is equivalent to
causing all intermediate operations to be computed using the base
In addition to setting the mode used for computation of intermediate
-gnato switch also enables overflow checking (which
is suppressed by default). It thus combines the effect of using
Overflow_Mode and pragma