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,ad4aec717fd8556e X-Google-Attributes: gid103376,public From: Ken Garlington Subject: Re: 'size attribute inheritance Date: 1997/08/11 Message-ID: <33EFCB66.285D@flash.net>#1/1 X-Deja-AN: 263644389 References: <33ECF679.4B5D@lmco.com> Organization: Flashnet Communications, http://www.flash.net Reply-To: Ken.Garlington@computer.org Newsgroups: comp.lang.ada Date: 1997-08-11T00:00:00+00:00 List-Id: Robert Dewar wrote: > > << When running this code, we get a bus alignment error. We tracked > it > down to the fact that the compiler does NOT really allocate 16 bits > for Month with subtype Month_Type. We assumed that since>> > > This is definitely a compiler bug, there is no way that legal declarations > that are accepted by the compiler can lead to bus errors. This seems like an odd statement. Maybe I'm not understanding the problem, but I thought the real issue was code like the following: package A_Test is Word : constant := 4; type Small_Value is range 0 .. 15; type A_Record is record Component_1 : Integer; Component_2 : Small_Value; end record; for A_Record use record Component_1 at 0*Word range 0 .. 31; Component_2 at 1*Word range 0 .. 31; end record; My_Record : A_Record := (3, 15); end A_Test; For this code, will My_Record.Component_2 be stored in bits 0 .. 3 of word 1, bits 28 .. 31, or elsewhere? I know in Ada83 that this sometimes ended up on one side, and something like type B_Array is array(0 .. 3) of Boolean; pragma Pack(B_Array); sometimes ended up on the other side. Is there something in the Ada83/Ada RMs that discuss this? I couldn't find it. > > However, the treatment of the size attribute seems to be quite in accord > with the RM. Ada 95 effectively introduced pretty serious incompatibilites > in the handling of 'Size by requiring an interpretaytion that was legal > in Ada 83 (and happened by no mere coincidence to be the one used by > the Intermetrics compiler :-) but was not typical of Ada 83 compilers. > > So a lot of old code breaks but the break should consist of rejections > at compile time: NOT bus errors! Yeah, I don't think 'Size is really the issue here. It's the behavior when a record representation clause allocates more space to a component that it needs. Unless there's something in the RM that controls this, I could see where a compiler might do something different than you might expect. For example, storing it in an "unconventional" manner might allow for fewer shift/mask instructions. > > GNAT has introduced new attributes Value_Size and Object_Size wjhich can > be applied to subtypes as well as first named types, to provide complete > control over sizes, and allow old code to be easily ported no matter what > conventions the compiler on which it was compiled was using. > > Our default conventions are as close as we are allowed to the VADS compiler, > but we are not allowed to be 100% compatible. In any case the bus error > is a serious bug. From the description, it does not sound like you are > using GNAT, and certainly the current version of GNAT does what you > expect with the declarations you gave.