comp.lang.ada
 help / color / mirror / Atom feed
From: Mark Johnson <Mark_H_Johnson@Raytheon.com>
Subject: Re: Confused about Attribute Size?
Date: Wed, 23 Jan 2002 08:56:24 -0600
Date: 2002-01-23T08:56:24-06:00	[thread overview]
Message-ID: <3C4ECF18.A9351D07@Raytheon.com> (raw)
In-Reply-To: 3C4E1DD9.D0B62FDE@acm.org

Jeffrey Carter wrote:
> 
> Mark Johnson wrote:
> >
> > > for My_Type'Size use 8;
> > >
> > Another representation specification. In this case, you are asking that
> > the 16 possible values to be stored in an eight bit byte (or larger).
> > There are several cases where the compiler can use more than 8 bits to
> > store My_Type...
> >  - a record component if the record is NOT packed
> >  - array components
> >  - a formal parameter passed to a function or procedure
> > There are several pages of dense text in the Annotated Ada Reference
> > Manual in section 13.3 that describes this in far more detail that I
> > will attempt to describe - especially to a newbie.
> 
> A 'Size specification on a type instructs the compiler to use that size
> for components of packed records and arrays. In most other cases
> (records with the layout specified is an exception), the compiler may
> use any size it chooses.
> 
> --
> Jeff Carter
> "Go and boil your bottoms."
> Monty Python & the Holy Grail

What you state is often true but not required behavior. The annotated
ARM says 13.3 (52.c)...
  Note that "for S2'Size use 5;" requires record components whose
subtype is S2 to be exactly 5 bits if the record type is packed. The
same is NOT TRUE [my emphasis] of array components; their Size MAY [my
emphasis] be rounded up to the nearest factor of word size. [what I
stated]

What you described is often true but not required behavior for an Ada
compiler.

I can also point you to a note in the GNAT 3.14a1 reference manual where
it states...
  GNAT treats packed arrays in one of two ways. If the size of the array
is known at compile time and is less than 64 bits, then internally the
array is represented as a single modular type, of exactly the
appropriate number of bits. [what you stated] If the length is greater
than 63 bits, or is not known at compile time, then the packed array is
represented as an array of bytes, and the length is always a multiple of
8 bits. [what I stated]

As I noted above, it is far more complicated than it appears.
  --Mark



  reply	other threads:[~2002-01-23 14:56 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-01-22  7:39 Confused about Attribute Size? Zebylon
2002-01-22 19:08 ` Patrick Hohmeyer
2002-01-22 22:56 ` Mark Johnson
2002-01-23  2:20   ` Jeffrey Carter
2002-01-23 14:56     ` Mark Johnson [this message]
2002-01-23 17:06       ` Jeffrey Carter
2002-01-24  4:11         ` Robert Dewar
  -- strict thread matches above, loose matches on Subject: below --
2002-01-22  8:00 Christoph Grein
replies disabled

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