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.3 required=5.0 tests=BAYES_00,INVALID_MSGID 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: dewar@merv.cs.nyu.edu (Robert Dewar) Subject: Re: 'size works for SunAda but not GNAT Date: 1996/10/09 Message-ID: #1/1 X-Deja-AN: 188366063 references: <53dv03$3ti@gcsin3.geccs.gecm.com> organization: New York University newsgroups: comp.lang.ada Date: 1996-10-09T00:00:00+00:00 List-Id: David asked "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). 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;" Which of these is better?" This was indeed Verdix dependent code. Verdix allows a size clause to affect the internal representation of an array, which GNAT does not. Both Ada 83 AI's and the Ada 95 RM: 53 A Size clause on a composite subtype should not affect the internal layout of components. recommend against this. Of your two solutions, the component size solution is portable. You can use a type, but you should still use a component clause. When you say type V is range 0 .. 63; GNAT happens to chose Short_Short_Integer as the base type, which has a default Object_Size of 8 bits, but some other implementation can chose a different base type and give a different default component size. Always specify all characteristics that are implementation dependent. A solution that would also work in both compilers is just to give a Size clause for the type or subtype. GNAT will use this size as the default component size, but again, this is not required, and you should really always specify the component size if it is important to you!