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: Stephen Leake Subject: Re: 'size works for SunAda but not GNAT Date: 1996/10/09 Message-ID: <325B9E3B.4AD9@gsfc.nasa.gov>#1/1 X-Deja-AN: 188238452 references: <53dv03$3ti@gcsin3.geccs.gecm.com> content-type: text/plain; charset=us-ascii organization: NASA Goddard Space Flight Center -- Greenbelt, Maryland USA mime-version: 1.0 reply-to: Stephen.Leake@gsfc.nasa.gov newsgroups: comp.lang.ada x-mailer: Mozilla 3.0 (Win95; U) Date: 1996-10-09T00:00:00+00:00 List-Id: David Haslam wrote: > > I have a lot of code like this, which compiles fine > with SunAda 1.1: > > 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". > GNAT wants V to be 32 bits, even though it can fit in 8. > > If GNAT is correct in rejecting this, then it implies that the > code we have is non-portable (and relied on a Verdix implementation > dependent feature). Well, non-portable between Ada83 and Ada95, at least. Although, I suspect there are other Ada83 compilers that reject this also. > If so, how do I write portable rep clauses? > 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;" > These are certainly good choices; 2 is not Ada83, but it is standard Ada95 (note that not all attributes GNAT supports are standard Ada95). > Which of these is better? If you want Ada83 portability, you have to pick 1. If you can use Ada95, 1 is better if ALL uses of type V must be 8 bits; 2 is better if only THIS use of V needs 8 bits. > > -- > David Haslam Work: David.Haslam@gecm.com > GEC-Marconi S3I Ltd Home: dch@sirius.demon.co.uk > Simulation and Training Division -- - Stephe