comp.lang.ada
 help / color / mirror / Atom feed
From: bobduff@world.std.com (Robert A Duff)
Subject: Re: Ada 95 Numerics questions for the experts
Date: 1997/08/30
Date: 1997-08-30T00:00:00+00:00	[thread overview]
Message-ID: <EFqz2G.4GG@world.std.com> (raw)
In-Reply-To: jeffrey.m.creem-2708970802350001@ljd155.sanders.lockheed.com


In article <jeffrey.m.creem-2708970802350001@ljd155.sanders.lockheed.com>,
Jeff Creem <jeffrey.m.creem@lmco.com> wrote:
>...The AdaMajic
>front end is even more limited than not allowing your cool example.
>Even something like
>
>type My_Type is range 0 .. 7;
>for My_Type'size use 3;
>type My_Array is array(1 .. 8) of M
>for My_Array'size use 24;
>
>Is not allowed because the element size of My_Arary is less than 8 it
>rounds to 8 for each element.

Any compiler that supports the above is broken (assuming a typical
32-bit machine).  I doubt if either GNAT or AdaMagic support it (can you
show the exact code you compiled on both compilers?).  A Size clause
does not control the internal layout of components.  Instead, you should use
"for My_Array'Component_Size use 3;" or "for My_Array'Component_Size use 4;"
or "pragma Pack(My_Array);".  Assuming a typical 32-bit machine, the
compiler must support 4-bit components (if it claims to support the SP
annex), and it *might* support 3-bit components -- this applies to both
Pack and Component_Size.  Component_Size is for when you care about the
exact size, whereas Pack is for when you want the compiler to minimize
space, but don't particularly care about (in this case) 3 vs. 4.

For a record with 8 3-bit components, on the other hand, the compiler
must support 3-bit packing.  Perhaps we should have required the same
for arrays that fit in a word.

Note that "for My_Type'size use 3;" is redundant -- My_Type'Size = 3 by
default.  You can put in the Size clause just to get a warm comfy
feeling that the compiler agrees with you on the size, if you like, but
it's not strictly necessary.

- Bob




      parent reply	other threads:[~1997-08-30  0:00 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <3401C14B.480@gsfc.nasa.gov>
1997-08-25  0:00 ` Ada 95 Numerics questions for the experts Robert Dewar
     [not found] ` <dewar.872560585@merv>
     [not found]   ` <jcreem-2608970711210001@ljd155.sanders.lockheed.com>
     [not found]     ` <dewar.872630607@merv>
     [not found]       ` <jeffrey.m.creem-2708970802350001@ljd155.sanders.lockheed.com>
1997-08-27  0:00         ` David C. Hoos, Sr.
1997-08-27  0:00           ` Robert Dewar
1997-08-27  0:00           ` Jeff Creem
1997-08-28  0:00             ` Robert Dewar
1997-08-28  0:00               ` Jeff Creem
1997-08-29  0:00               ` Tucker Taft
1997-08-30  0:00                 ` Robert A Duff
1997-08-31  0:00                 ` Tom Moran
1997-09-01  0:00                 ` Robert Dewar
1997-09-01  0:00                 ` Robert Dewar
1997-09-02  0:00                   ` Fergus Henderson
1997-09-02  0:00                   ` Robert A Duff
     [not found]                   ` <mheaney-ya023680000209972104030001@news.ni.net>
1997-09-05  0:00                     ` Robert Dewar
1997-09-05  0:00                       ` Matthew Heaney
1997-09-08  0:00                         ` Robert A Duff
1997-09-08  0:00                           ` Matthew Heaney
1997-09-09  0:00                             ` Robert A Duff
     [not found]                     ` <EFxt94.F5F@world.std.com>
1997-09-06  0:00                       ` Robert Dewar
1997-09-08  0:00                         ` Robert A Duff
1997-09-08  0:00                           ` Matthew Heaney
1997-09-09  0:00                             ` Robert A Duff
1997-08-27  0:00         ` Robert Dewar
     [not found]           ` <jeffrey.m.creem-2808970708260001@ljd155.sanders.lockheed.com>
1997-08-28  0:00             ` Robert Dewar
1997-08-30  0:00         ` Robert A Duff [this message]
replies disabled

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