comp.lang.ada
 help / color / mirror / Atom feed
From: Alan Brain <aebrain@dynamite.com.au>
Subject: Re: 'size works for SunAda but not GNAT
Date: 1996/10/11
Date: 1996-10-11T00:00:00+00:00	[thread overview]
Message-ID: <325DFA7E.22CA@dynamite.com.au> (raw)
In-Reply-To: 53dv03$3ti@gcsin3.geccs.gecm.com


David Haslam wrote:
> 
> I have a lot of code like this

>         subtype V is integer range 0..63;
>         type A is array (1..9) of V;
>         for A'size use 9 * 8;
> 
> GNAT complains "size for A must be at least 288".

> There are two ways of fixing the code for GNAT:
> 1. use a type instead of a subtype
> 2. add the line: "for A'component_size use 8;"
> 
> Which of these is better?

2, definitely.
When using rep clauses, it is good engineering practice to specify
everything, every component. Why? Because there are so many ways for
different compilers to use different representations in records (for
example). It's easy to miss one bit, the compiler doesn't complain, but
the memory dump shows a memory allocation quite different from the one
intended. I know from personal and painful experience in defining a data
type used for communications between an i860 and a KAV-30.

I'd also put in some "use at mod..." clauses as well, many compilers
insist on word boundaries for large objects.

----------------------      <> <>    How doth the little Crocodile
| Alan & Carmel Brain|      xxxxx       Improve his shining tail?
| Canberra Australia |  xxxxxHxHxxxxxx _MMMMMMMMM_MMMMMMMMM
---------------------- o OO*O^^^^O*OO o oo     oo oo     oo  
                    By pulling Maerklin Wagons, in 1/220 Scale




  parent reply	other threads:[~1996-10-11  0:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-10-08  0:00 'size works for SunAda but not GNAT David Haslam
1996-10-09  0:00 ` Robert Dewar
1996-10-09  0:00 ` Stephen Leake
1996-10-11  0:00 ` Alan Brain [this message]
1996-10-11  0:00   ` Robert Dewar
replies disabled

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