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,fd173879a595bde X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!cyclone1.gnilink.net!spamkiller.gnilink.net!gnilink.net!trnddc08.POSTED!20ae255c!not-for-mail Newsgroups: comp.lang.ada From: Anonymous Coward Subject: Re: Default rep specs for record types - documented?? References: Message-Id: User-Agent: slrn/0.9.7.4 (Linux) Date: Mon, 14 Nov 2005 03:03:38 GMT NNTP-Posting-Host: 141.149.78.234 X-Complaints-To: abuse@verizon.net X-Trace: trnddc08 1131937418 141.149.78.234 (Sun, 13 Nov 2005 22:03:38 EST) NNTP-Posting-Date: Sun, 13 Nov 2005 22:03:38 EST Xref: g2news1.google.com comp.lang.ada:6366 Date: 2005-11-14T03:03:38+00:00 List-Id: In article , Robert A Duff wrote: > "Steve" writes: > >> But if you add a representation clause: >> >> for Color'size use 8; >> >> All compilers will use the same number of bits to represent an instance of >> color? > > No (unfortunately). It means "use at least 8 bits for objects". > A compiler is free to allocate 32. To control the size of objects, > you have to use 'Size on the object, or, if it's a component, > a record rep clause or a 'Component_Size on an array. I keep getting to a point where I think I've mastered these rep specs, and yet more gotchas emerge. I had no idea I could control the representation of objects independant of the representation of their types. I'm shocked to hear that size specs on types are merely a *minimum*. Can I at least rely on pragma convention to guarantee an absolute size on enums/integers? As for records, I've imposed sizes on all my rep spec'd record types. It would normally be needless, but to protect the maintainer from accidentally defining a partial rep spec as the operational spec grows, I've added a size spec so an error will be thrown at compile time. It seems your statement about size specs on types only being a minimum does not apply to record types, correct? Here is some code that fails to compile because the operational spec forces growth beyond that of the size spec: procedure Record_Experiment is type Cuban_Aid_In_USD is range 0..50_000; type Bushs_Record is record Iraq_WoMD_Count : Natural; Dead_Americans : Positive; Dead_Civilians : Positive; Deficit_In_Thousands : Integer; Aid_Offered_To_Cuba : Cuban_Aid_In_USD; end record; for Bushs_Record use record Iraq_WoMD_Count at 0 range 0..31; Dead_Americans at 4 range 0..31; Dead_Civilians at 8 range 0..31; Deficit_In_Thousands at 12 range 0..31; end record; --The following line breaks the compile, --which is expected and desirable. -- for Bushs_Record'Size use 128; President : Bushs_Record; --The following line just illustrates that --the object size spec can differ from the --type size spec. -- for President'Size use 160; begin null; end Record_Experiment; In this case, I added "Aid_Offered_To_Cuba" to the operational spec, forcing the record to exceed 128 bytes, which causes an error. This seems like the best protection, but it's still inadequite because a neglectful maintainer can still increase the size spec without completing the layout.