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=0.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,ee9f582dbd8ab972 X-Google-Attributes: gid103376,public From: Alan Brain Subject: Re: 'size works for SunAda but not GNAT Date: 1996/10/11 Message-ID: <325DFA7E.22CA@dynamite.com.au>#1/1 X-Deja-AN: 188589034 references: <53dv03$3ti@gcsin3.geccs.gecm.com> content-type: text/plain; charset=us-ascii organization: @Home mime-version: 1.0 reply-to: aebrain@dynamite.com.au newsgroups: comp.lang.ada x-mailer: Mozilla 3.0 (Win16; I) Date: 1996-10-11T00:00:00+00:00 List-Id: David Haslam wrote: > > I have a lot of code like this > subtype V is integer range 0..63; > type A is array (1..9) of V; > for A'size use 9 * 8; > > GNAT complains "size for A must be at least 288". > There are two ways of fixing the code for GNAT: > 1. use a type instead of a subtype > 2. add the line: "for A'component_size use 8;" > > Which of these is better? 2, definitely. When using rep clauses, it is good engineering practice to specify everything, every component. Why? Because there are so many ways for different compilers to use different representations in records (for example). It's easy to miss one bit, the compiler doesn't complain, but the memory dump shows a memory allocation quite different from the one intended. I know from personal and painful experience in defining a data type used for communications between an i860 and a KAV-30. I'd also put in some "use at mod..." clauses as well, many compilers insist on word boundaries for large objects. ---------------------- <> <> How doth the little Crocodile | Alan & Carmel Brain| xxxxx Improve his shining tail? | Canberra Australia | xxxxxHxHxxxxxx _MMMMMMMMM_MMMMMMMMM ---------------------- o OO*O^^^^O*OO o oo oo oo oo By pulling Maerklin Wagons, in 1/220 Scale