Ada Conformity Assessment Authority      Home Conformity Assessment   Test Suite ARGAda Standard
Ada Reference Manual (Ada 2022 Draft 35)Legal Information
Contents   Index   References   Search   Previous   Next 

13.9.2 The Valid Attribute

The Valid attribute can be used to check the validity of data produced by unchecked conversion, input, interface to foreign languages, and the like. 

Static Semantics

For a prefix X that denotes a scalar object (after any implicit dereference), the following attribute is defined: 
Yields True if and only if the object denoted by X is normal, has a valid representation, and then, if the preceding conditions hold, the value of X also satisfies the predicates of the nominal subtype of X. The value of this attribute is of the predefined type Boolean. 
NOTE 1   Invalid data can be created in the following cases (not counting erroneous or unpredictable execution): 
an uninitialized scalar object,
the result of an unchecked conversion,
interface to another language (including machine code),
aborting an assignment,
disrupting an assignment due to the failure of a language-defined check (see 11.6), and
use of an object whose Address has been specified. 
NOTE 2   Determining whether X is normal and has a valid representation as part of the evaluation of X'Valid is not considered to include an evaluation of X; hence, it is not an error to check the validity of an object that is invalid or abnormal. Determining whether X satisfies the predicates of its nominal subtype can include an evaluation of X, but only after it has been determined that X has a valid representation.
If X is volatile, the evaluation of X'Valid is considered a read of X.
NOTE 3   The Valid attribute can be used to check the result of calling an instance of Unchecked_Conversion (or any other operation that can return invalid values). However, an exception handler is still useful because implementations are permitted to raise Constraint_Error or Program_Error if they detect the use of an invalid representation (see 13.9.1).

Contents   Index   References   Search   Previous   Next 
Ada-Europe Ada 2005 and 2012 Editions sponsored in part by Ada-Europe