4.9. Static Expressions and Static Subtypes


Certain expressions of a scalar type are said to be static. Similarly, certain discrete ranges are said to be static, and the type marks of certain scalar subtypes are said to denote static subtypes.

An expression of a scalar type is said to be static if and only if every primary is one of those listed in (a) through (h) below, every operator denotes a predefined operator, and the evaluation of the expression delivers a value (that is, it does not raise an exception):

  1. An enumeration literal (including a character literal).

  2. A numeric literal.

  3. A named number.

  4. A constant explicitly declared by a constant declaration with a static subtype, and initialized with a static expression.

  5. A function call whose function name is an operator symbol that denotes a predefined operator, including a function name that is an expanded name; each actual parameter must also be a static expression.

  6. A language-defined attribute of a static subtype; for an attribute that is a function, the actual parameter must also be a static expression.

  7. A qualified expression whose type mark denotes a static subtype and whose operand is a static expression.

  8. A static expression enclosed in parentheses.

A static range is a range whose bounds are static expressions. A static range constraint is a range constraint whose range is static. A static subtype is either a scalar base type, other than a generic formal type; or a scalar subtype formed by imposing on a static subtype either a static range constraint, or a floating or fixed point constraint whose range constraint, if any, is static. A static discrete range is either a static subtype or a static range. A static index constraint is an index constraint for which each index subtype of the corresponding array type is static, and in which each discrete range is static. A static discriminant constraint is a discriminant constraint for which the subtype of each discriminant is static, and in which each expression is static.


The accuracy of the evaluation of a static expression having a real type is defined by the rules given in section 4.5.7. If the result is not a model number (or a safe number) of the type, the value obtained by this evaluation at compilation time need not be the same as the value that would be obtained by an evaluation at run time.

Array attributes are not static: in particular, the RANGE attribute is not static.

References: actual parameter, attribute, base type, bound of a range, character literal, constant, constant declaration, discrete range, discrete type, enumeration literal, exception, expression, function, generic actual parameter, generic formal type, implicit declaration, initialize, model number, named number, numeric literal, predefined operator, qualified expression, raising of exceptions, range constraint, safe number, scalar type, subtype, type mark.