From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.5 required=5.0 tests=BAYES_00,FREEMAIL_FROM, INVALID_MSGID,PP_MIME_FAKE_ASCII_TEXT autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII X-Google-Thread: 103376,fd398ca223dbbfd6 X-Google-Attributes: gid103376,public From: "Vladimir Olensky" Subject: Re: 'Size (novice question) Date: 2000/02/22 Message-ID: #1/1 X-Deja-AN: 588410051 References: <38ACA68D.CEA7E03F@interact.net.au> Organization: Posted via Supernews, http://www.supernews.com X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3 Newsgroups: comp.lang.ada X-Complaints-To: newsabuse@supernews.com Date: 2000-02-22T00:00:00+00:00 List-Id: Lutz Donnerhacke wrote in message ... >* Robert A Duff wrote: >>The important thing to remember is that if you say: >> >> X: Byte; >> >>then (surprise!) X'Size might be 8, or might be 32, whether or not the >>above Size clause is there. The language rules just say X'Size >= >>Byte'Size. >>The compiler should choose whatever is most efficient. If >>you really want X to be 8 bits, say "for X'Size use 8;". Likewise, if > >Funny. Though what is said above is generally true I see no reason to worry about that much. According to LRM 13.3 (50) compiler should use the same size for object as the size of it's type provided that this size provides independent addressability : ===================================================== Implementation Advice: 50 If the Size of a subtype is specified, and allows for efficient independent addressability (see 9.10) on the target architecture, then the Size of the following objects of the subtype should equal the Size of the subtype: 51 � Aliased objects (including components). 52 � Unaliased components, unless the Size of the component is determined by a component_clause or Component_Size clause. .... 54 The recommended level of support for the Size attribute of subtypes is: 55 � The Size (if not specified) of a static discrete or fixed point subtype should be the number of bits needed to represent each value belonging to the subtype using an unbiased representation, leaving space for a sign bit only if the subtype contains negative values. If such a subtype is a first subtype, then an implementation should support a specified Size for it that reflects this representation. ============================================ As I understand efficient independent addressability means that the X'Size should be multiple of storage_units. It would be strange to hear that separate storage unit could not be addressed efficiently. So if X_Type'Size is multiple of storage_unit than X'Size should be the same. At least on IA32 platform storage_unit is equal one byte. So if you have : type Byte_type is mod 2**8; type Bits5_type is mod 2**5; type Bits10_type is mod 2**10; A : byte_type; B : Bits5_type; C: Bits10_type; then according to 13.3 (55): Byte_Type'Size = 8; Bits5_type'Size = 5; Bits10_type'Size =10; if ( storage_unit = 8) then A'Size = 8; B'Size = 8; C'Size =16; end if; if ( storage_unit = 32) then A'Size = 32; B'Size = 32; C'Size = 32; end if; Regards, Vladimir Olensky