Ada Conformity Assessment Authority      Home Conformity Assessment   Test Suite ARGAda Standard
Overview of Ada 2022
Jeff Cousins
Contents   Index   Search   Previous   Next 

7.3 Object_Size attribute

Object_Size attribute (AI12-0059) adds the Object_Size attribute (see RM 13.3). Users have been after this since 1983! S'Object_Size denotes the size of an object of subtype S. It can be specified, but must be specified to a value that the compiler is able to allocate (usually an entire storage unit for most implementations).
S'Object_Size is an improvement on S'Size (which cannot be redefined without breaking existing code). Reading S'Size is not terribly useful as it just gives the theoretical minimum number of bits required for a value of a given range, not the number of bits that the compiler is actually going to allocate to an object of the type. Specifying S'Size just gives a minimum, the compiler may allocate more. In contrast, S'Object_Size specifies the exact size that will be allocated in the absence of the specification of the representation in some other way (for instance, by specifying X'Size for an object X or by specifying the layout of a record component with a record representation clause).

Contents   Index   Search   Previous   Next 
© 2021, 2022 Jeff Cousins