comp.lang.ada
 help / color / mirror / Atom feed
From: "Adam Beneschan" <adam@irvine.com>
Subject: Re: Size of objects in records with an array.
Date: 24 Oct 2006 14:02:10 -0700
Date: 2006-10-24T14:02:10-07:00	[thread overview]
Message-ID: <1161723730.851354.114970@k70g2000cwa.googlegroups.com> (raw)
In-Reply-To: 1161713194.952748.280790@h48g2000cwc.googlegroups.com

Richard Charts wrote:

> Bah!
> So obvious.
> Thank you very much.
> Out of curiousity would the following lines be equivalent?
> I know both compile.
>
> for Bit_Array'Component_Size use 1;
>
> for Bit_Array'Size use 24;

This is implementation-dependent.  However, if the latter clause
compiles and *doesn't* cause the 'Component_Size to be changed to 1, I
think there has to be a bug in the compiler.  It's possible that the
'Size clause may not compile.

RM 13.3(53) says, "A Size clause on a composite subtype should not
affect the internal layout of components."

and the AARM says, in that regard,

"On most machines, arrays don't contain gaps between elementary
components; if the Component_Size is greater than the Size of the
component subtype, the extra bits are generally considered part of each
component, rather than gaps between components."

and

 "For an array, any extra bits stored for each elementary component
will generally be part of the component".

That means that if the normal implementation of a Boolean array is to
put one Boolean in each 8-bit byte, then each component is an 8-bit
object, and having the 'Size clause change the 'Component_Size to 1
would thus affect the internal layout of the components and thus go
against the RM.  However, this is open to interpretation (translation:
I may be all wet), and it's all under Implementation Advice anyway, so
implementations can allow the 'Size clause if they wish.

But I'd use the 'Component_Size clause instead of 'Size.  The former
should work, the latter may be rejected.

                         -- Adam




  reply	other threads:[~2006-10-24 21:02 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-10-24 17:48 Size of objects in records with an array Richard Charts
2006-10-24 17:56 ` Robert A Duff
2006-10-24 18:06   ` Richard Charts
2006-10-24 21:02     ` Adam Beneschan [this message]
2006-10-26 23:53     ` Robert A Duff
replies disabled

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