Next: , Previous: , Up: Implementation Defined Attributes   [Contents][Index]


4.14 Attribute Descriptor_Size

Nonstatic attribute Descriptor_Size returns the size in bits of the descriptor allocated for a type. The result is non-zero only for unconstrained array types and the returned value is of type universal integer. In GNAT, an array descriptor contains bounds information and is located immediately before the first element of the array.

type Unconstr_Array is array (Positive range <>) of Boolean;
Put_Line ("Descriptor size = " & Unconstr_Array'Descriptor_Size'Img);

The attribute takes into account any additional padding due to type alignment. In the example above, the descriptor contains two values of type Positive representing the low and high bound. Since Positive has a size of 31 bits and an alignment of 4, the descriptor size is 2 * Positive’Size + 2 or 64 bits.