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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,d9523383d7eb42d0 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-01-23 06:56:44 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!bloom-beacon.mit.edu!nycmny1-snh1.gtei.net!cambridge1-snf1.gtei.net!news.gtei.net!bos-service1.ext.raytheon.com!dfw-service2.ext.raytheon.com.POSTED!not-for-mail Message-ID: <3C4ECF18.A9351D07@Raytheon.com> From: Mark Johnson X-Mailer: Mozilla 4.5 [en] (WinNT; I) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Confused about Attribute Size? References: <3C4DEE09.B34A579@Raytheon.com> <3C4E1DD9.D0B62FDE@acm.org> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Date: Wed, 23 Jan 2002 08:56:24 -0600 NNTP-Posting-Host: 192.27.48.44 X-Complaints-To: news@ext.ray.com X-Trace: dfw-service2.ext.raytheon.com 1011797803 192.27.48.44 (Wed, 23 Jan 2002 08:56:43 CST) NNTP-Posting-Date: Wed, 23 Jan 2002 08:56:43 CST Organization: Raytheon Company Xref: archiver1.google.com comp.lang.ada:19236 Date: 2002-01-23T08:56:24-06:00 List-Id: Jeffrey Carter wrote: > > Mark Johnson wrote: > > > > > for My_Type'Size use 8; > > > > > Another representation specification. In this case, you are asking that > > the 16 possible values to be stored in an eight bit byte (or larger). > > There are several cases where the compiler can use more than 8 bits to > > store My_Type... > > - a record component if the record is NOT packed > > - array components > > - a formal parameter passed to a function or procedure > > There are several pages of dense text in the Annotated Ada Reference > > Manual in section 13.3 that describes this in far more detail that I > > will attempt to describe - especially to a newbie. > > A 'Size specification on a type instructs the compiler to use that size > for components of packed records and arrays. In most other cases > (records with the layout specified is an exception), the compiler may > use any size it chooses. > > -- > Jeff Carter > "Go and boil your bottoms." > Monty Python & the Holy Grail What you state is often true but not required behavior. The annotated ARM says 13.3 (52.c)... Note that "for S2'Size use 5;" requires record components whose subtype is S2 to be exactly 5 bits if the record type is packed. The same is NOT TRUE [my emphasis] of array components; their Size MAY [my emphasis] be rounded up to the nearest factor of word size. [what I stated] What you described is often true but not required behavior for an Ada compiler. I can also point you to a note in the GNAT 3.14a1 reference manual where it states... GNAT treats packed arrays in one of two ways. If the size of the array is known at compile time and is less than 64 bits, then internally the array is represented as a single modular type, of exactly the appropriate number of bits. [what you stated] If the length is greater than 63 bits, or is not known at compile time, then the packed array is represented as an array of bytes, and the length is always a multiple of 8 bits. [what I stated] As I noted above, it is far more complicated than it appears. --Mark