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,ffdd4d59cbfb4caf X-Google-Attributes: gid103376,public From: bobduff@world.std.com (Robert A Duff) Subject: Re: Ada 95 Numerics questions for the experts Date: 1997/08/30 Message-ID: #1/1 X-Deja-AN: 269115714 References: <3401C14B.480@gsfc.nasa.gov> Organization: The World Public Access UNIX, Brookline, MA Newsgroups: comp.lang.ada Date: 1997-08-30T00:00:00+00:00 List-Id: In article , Jeff Creem wrote: >...The AdaMajic >front end is even more limited than not allowing your cool example. >Even something like > >type My_Type is range 0 .. 7; >for My_Type'size use 3; >type My_Array is array(1 .. 8) of M >for My_Array'size use 24; > >Is not allowed because the element size of My_Arary is less than 8 it >rounds to 8 for each element. Any compiler that supports the above is broken (assuming a typical 32-bit machine). I doubt if either GNAT or AdaMagic support it (can you show the exact code you compiled on both compilers?). A Size clause does not control the internal layout of components. Instead, you should use "for My_Array'Component_Size use 3;" or "for My_Array'Component_Size use 4;" or "pragma Pack(My_Array);". Assuming a typical 32-bit machine, the compiler must support 4-bit components (if it claims to support the SP annex), and it *might* support 3-bit components -- this applies to both Pack and Component_Size. Component_Size is for when you care about the exact size, whereas Pack is for when you want the compiler to minimize space, but don't particularly care about (in this case) 3 vs. 4. For a record with 8 3-bit components, on the other hand, the compiler must support 3-bit packing. Perhaps we should have required the same for arrays that fit in a word. Note that "for My_Type'size use 3;" is redundant -- My_Type'Size = 3 by default. You can put in the Size clause just to get a warm comfy feeling that the compiler agrees with you on the size, if you like, but it's not strictly necessary. - Bob