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 09:15:02 PST Newsgroups: comp.lang.ada Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newspeer.radix.net!uunet!ash.uu.net!xyzzy!nntp From: Jeffrey Carter Subject: Re: Confused about Attribute Size? X-Nntp-Posting-Host: e246420.msc.az.boeing.com Content-Type: text/plain; charset=us-ascii Message-ID: <3C4EEDAA.10377A9C@boeing.com> Sender: nntp@news.boeing.com (Boeing NNTP News Access) Content-Transfer-Encoding: 7bit Organization: The Boeing Company X-Accept-Language: en References: <3C4DEE09.B34A579@Raytheon.com> <3C4E1DD9.D0B62FDE@acm.org> <3C4ECF18.A9351D07@Raytheon.com> Mime-Version: 1.0 Date: Wed, 23 Jan 2002 17:06:50 GMT X-Mailer: Mozilla 4.73 [en]C-CCK-MCD Boeing Kit (WinNT; U) Xref: archiver1.google.com comp.lang.ada:19245 Date: 2002-01-23T17:06:50+00:00 List-Id: Mark Johnson wrote: > > Jeffrey Carter wrote: > > > > 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. > > 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] Since a compiler may ignore pragma Pack completely, a 'Size specification does not require any behavior (except possibly the size of the Source parameter for an instance of Ada.Unchecked_Conversion). Even when a compiler packs a record, it may use a larger size than 'Size for a component or add padding [ARM 13.2(7)]. So a 'Size specification on a type is an instruction to the compiler, but that instruction may be ignored in most cases. In practice, most compilers do an excellent job of packing records. Most compilers also do an excellent job of packing arrays when 'Component_Size is specified for the array type. -- Jeffrey Carter