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,start X-Google-Attributes: gid103376,public From: Carlos Palenzuela Subject: 'size attribute inheritance Date: 1997/08/09 Message-ID: <33ECF679.4B5D@lmco.com>#1/1 X-Deja-AN: 263132782 Organization: Sprint Reply-To: cpalenzuela@sprintmail.com Newsgroups: comp.lang.ada Date: 1997-08-09T00:00:00+00:00 List-Id: Our software group has run across a problem with types and subtypes and their sizes that is confusing me. I have read what I believe to be the appropriate sections of the ARM, but I still need some clarification and would like to hear some informed opinions. Following is a simplified version of our example. We are using Green Hills Ada 95 targeted to Sun/Solaris. type Integer_16 is range -(2**15) .. (2**15)-1; for Integer_16'size use 16; subtype Natural_16 is Integer_16 range 0 .. Integer_16'last; subtype Month_Type is Natural_16 range 0..11; type Date_Type is record Year : Natural_16; Month : Month_Type; end record; for Date_Type use record Year at 0 range 0 .. 15; Month at 0 range 16 .. 31; end record; ... 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 Integer_16 had been set up with 'size attribute of 16, subtype Natural_16 would inherit that and so Month_Type would also inherit it. I might expect based on 13.3 (55) that Month_Type'size = 4 and then on 13.3 (43) that Month'size >= 4. Perhaps the confusion is that only the attribute itself and not its specific value is what is inherited; I don't see anything in the ARM which says one way or the other. Putting a 'size attribute on the subtype resulted in a syntax error [assumedly based on 13.3 (48)]. It's not necessarily so bad that Month_type'size and Month'size are different from Integer_16'size, but I would at least expect the values of Month to be right-justified in the record-component field if Month'size < Integer_16'size (as here), but instead it is left-justified! Is there a justification in the ARM for this or is this a compiler issue? We worked around this problem by setting up Month_Type as a type, rather than a subtype, and assigning it a 'size of 16, but the issue still has me perplexed. I would appreciate any informed opinions as to what I can or should expect about the inheritance of the 'size attribute. Thank you for your help, Lizbeth Palenzuela (working at but not speaking for) Lockheed Martin Integrated Systems Orlando, FL