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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,5a3e508f74e87110,start X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,CP1252 Path: g2news2.google.com!postnews.google.com!r33g2000yqn.googlegroups.com!not-for-mail From: =?ISO-8859-1?Q?Hibou57_=28Yannick_Duch=EAne=29?= Newsgroups: comp.lang.ada Subject: Record representation : components order Date: Sat, 4 Jul 2009 14:08:58 -0700 (PDT) Organization: http://groups.google.com Message-ID: <908a786e-214e-436f-868b-c0ead259fcc5@r33g2000yqn.googlegroups.com> NNTP-Posting-Host: 86.75.149.137 Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1246741738 25517 127.0.0.1 (4 Jul 2009 21:08:58 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Sat, 4 Jul 2009 21:08:58 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: r33g2000yqn.googlegroups.com; posting-host=86.75.149.137; posting-account=vrfdLAoAAAAauX_3XwyXEwXCWN3A1l8D User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; fr),gzip(gfe),gzip(gfe) Xref: g2news2.google.com comp.lang.ada:6836 Date: 2009-07-04T14:08:58-07:00 List-Id: Good evening to all (evening time here - good morning for the others), I was looking back at the RM section 13, =93 Representation issues =94 for records. First of all, I noticed somehing I had forgot, with an nice example in annotion > 44 For every subtype S: > 45 S'Size If S is definite, denotes the size [(in bits)] that the impl= ementation would > choose for the following objects of subtype S: > 46 A record component of subtype S when the record type is packed. > 47 The formal parameter of an instance of Unchecked_Conversion that co= nverts from > subtype S to some other subtype. If a packed record .... or a formal parameter of an unchecked conversion. To not to be forgotten, otherwise the implementation is not required to enforce the size attribute given to a subtype, unlinke when the size attribute is given to an instance of a subtype. The annotation later: > 55.j The fact that the size of an object is not necessarily the same as = its subtype can > be confusing: > 55.k type Device_Register is range 0..2**8 - 1; > for Device_Register'Size use 8; -- Confusing! > My_Device : Device_Register; > for My_Device'Address use To_Address(16#FF00#); 55.l The programmer might think that My_Device'Size is 8, and that My_Device'Address > points at an 8-bit location. However, this is not true. In Ada 83= (and in Ada 95), > My_Device'Size might well be 32, and My_Device'Address might well = point at the high-order > 8 bits of the 32-bit object, which are always all zero bits. Indeed, confusing But the question is not there (I point it for concerned people) Going on in section 13, I did no see about record components order apart the =93 at X range Y .. Z =94 which directly specify it. But looking at some design in some place in the web, people usually do this way : define some component type with a size clause, and then, just use these type in some records, most of time, without using any =93 at X range Y .. Z =94 . But to me, this seems to be unsafe, beceause components order is not guaranted to be that of the declaration. Is there something I missed ? I was thinking that an Ada compiler was allowed to reorder component of a record if it can helps some efficiency (I know at least a case, where this could help on some old machine) and thus that the declaration is a the declaration and the physical repsentation is not required to match what one might suppose, unless explicitely specified. But I did not see anything which assert that simply using sized types and design records with it and a pragma pack without any =93 at range =94 can ensure this. I did not see about the effect of a pragma convention on a representation. Is it related ?