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-Thread: 103376,d1fe9a910cd0ca57 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!postnews.google.com!k70g2000cwa.googlegroups.com!not-for-mail From: "Adam Beneschan" Newsgroups: comp.lang.ada Subject: Re: Size of objects in records with an array. Date: 24 Oct 2006 14:02:10 -0700 Organization: http://groups.google.com Message-ID: <1161723730.851354.114970@k70g2000cwa.googlegroups.com> References: <1161712138.465357.295460@i42g2000cwa.googlegroups.com> <1161713194.952748.280790@h48g2000cwc.googlegroups.com> NNTP-Posting-Host: 66.126.103.122 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: posting.google.com 1161723736 32504 127.0.0.1 (24 Oct 2006 21:02:16 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 24 Oct 2006 21:02:16 +0000 (UTC) User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.7.12) Gecko/20050922 Fedora/1.7.12-1.3.1,gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: k70g2000cwa.googlegroups.com; posting-host=66.126.103.122; posting-account=cw1zeQwAAABOY2vF_g6V_9cdsyY_wV9w Xref: g2news2.google.com comp.lang.ada:7189 Date: 2006-10-24T14:02:10-07:00 List-Id: Richard Charts wrote: > Bah! > So obvious. > Thank you very much. > Out of curiousity would the following lines be equivalent? > I know both compile. > > for Bit_Array'Component_Size use 1; > > for Bit_Array'Size use 24; This is implementation-dependent. However, if the latter clause compiles and *doesn't* cause the 'Component_Size to be changed to 1, I think there has to be a bug in the compiler. It's possible that the 'Size clause may not compile. RM 13.3(53) says, "A Size clause on a composite subtype should not affect the internal layout of components." and the AARM says, in that regard, "On most machines, arrays don't contain gaps between elementary components; if the Component_Size is greater than the Size of the component subtype, the extra bits are generally considered part of each component, rather than gaps between components." and "For an array, any extra bits stored for each elementary component will generally be part of the component". That means that if the normal implementation of a Boolean array is to put one Boolean in each 8-bit byte, then each component is an 8-bit object, and having the 'Size clause change the 'Component_Size to 1 would thus affect the internal layout of the components and thus go against the RM. However, this is open to interpretation (translation: I may be all wet), and it's all under Implementation Advice anyway, so implementations can allow the 'Size clause if they wish. But I'd use the 'Component_Size clause instead of 'Size. The former should work, the latter may be rejected. -- Adam