comp.lang.ada
 help / color / mirror / Atom feed
* 'size attribute inheritance
@ 1997-08-09  0:00 Carlos Palenzuela
  1997-08-10  0:00 ` Robert A Duff
                   ` (2 more replies)
  0 siblings, 3 replies; 22+ messages in thread
From: Carlos Palenzuela @ 1997-08-09  0:00 UTC (permalink / raw)



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




^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~1997-09-08  0:00 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-08-09  0:00 'size attribute inheritance Carlos Palenzuela
1997-08-10  0:00 ` Robert A Duff
1997-08-10  0:00 ` Matthew Heaney
1997-08-11  0:00   ` Robert Dewar
1997-08-12  0:00     ` Matthew Heaney
1997-08-13  0:00       ` Ken Garlington
1997-08-13  0:00         ` Matthew Heaney
1997-08-13  0:00       ` Robert A Duff
1997-08-13  0:00         ` Matthew Heaney
1997-08-14  0:00           ` Robert A Duff
1997-08-14  0:00             ` Dale Stanbrough
1997-08-16  0:00           ` Robert Dewar
1997-08-16  0:00             ` Ken Garlington
1997-08-17  0:00               ` Robert A Duff
1997-08-17  0:00               ` Robert Dewar
1997-08-18  0:00                 ` Robert A Duff
     [not found]                   ` <dewar.872433846@merv>
1997-09-03  0:00                     ` Robert A Duff
1997-09-06  0:00                       ` Robert Dewar
1997-09-08  0:00                         ` Robert A Duff
1997-08-10  0:00 ` Robert Dewar
1997-08-11  0:00   ` Ken Garlington
1997-08-11  0:00   ` Matthew Heaney

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox