pragma Assume_No_Invalid_Values (On | Off);
This is a configuration pragma that controls the assumptions made by the compiler about the occurrence of invalid representations (invalid values) in the code.
The default behavior (corresponding to an Off argument for this pragma), is to assume that values may in general be invalid unless the compiler can prove they are valid. Consider the following example:
V1 : Integer range 1 .. 10; V2 : Integer range 11 .. 20; ... for J in V2 .. V1 loop ... end loop;
if V1 and V2 have valid values, then the loop is known at compile
time not to execute since the lower bound must be greater than the
upper bound. However in default mode, no such assumption is made,
and the loop may execute. If Assume_No_Invalid_Values (On)
is given, the compiler will assume that any occurrence of a variable
other than in an explicit 'Valid
test always has a valid
value, and the loop above will be optimized away.
The use of Assume_No_Invalid_Values (On)
is appropriate if
you know your code is free of uninitialized variables and other
possible sources of invalid representations, and may result in
more efficient code. A program that accesses an invalid representation
with this pragma in effect is erroneous, so no guarantees can be made
about its behavior.
It is peculiar though permissible to use this pragma in conjunction with validity checking (-gnatVa). In such cases, accessing invalid values will generally give an exception, though formally the program is erroneous so there are no guarantees that this will always be the case, and it is recommended that these two options not be used together.