comp.lang.ada
 help / color / mirror / Atom feed
From: Robert Dewar <robert_dewar@my-deja.com>
Subject: Re: GNAT bug with respect to an Implementation Advise
Date: Thu, 14 Dec 2000 01:40:13 GMT
Date: 2000-12-14T01:40:13+00:00	[thread overview]
Message-ID: <9198ds$n3o$1@nnrp1.deja.com> (raw)
In-Reply-To: t3f6rg54jlkfee@corp.supernews.com

In article <t3f6rg54jlkfee@corp.supernews.com>,
  "Jeff Creem" <jeff@thecreems.com> wrote:
> The LRM has an implementation advice that says:
>
> 13.13.2(17): Stream Oriented Attributes


The RM is actually a little unclear here, since it
is not clear how subtypes should be treated when they

have different in memory sizes from the base type.

For example, suppose we write:

   type x is range 1 .. 1000;
   for x'size use 16;
   subtype y is x range 1 .. 10;
   xx : x;
   yy : y;

Now we can imagine several implementations, all valid
from the RM:

1. xx, yy both take 32 bits in memory
2. xx, yy both take 16 bits
3. xx takes 16 bits, yy takes 8 bits

Now you can imagine these three implementations
trying to follow the RM generating three different
streams, which seems unfortunately unportable, given
that the IA is presumably trying to create
uniformity.

What we did in GNAT was to decide that "normal in
memory representation" meant the space that the base
type would take, regardless of the space actually
occupied by individual subtype variables. But at
least one other implementation took approach 3.

So the RM is not the issue here, both these
implementations are following a reasonable
interpretation of the RM requirement.

What's wrong is the RM requirement!

What the AI did here was to normalize the stream
requirement to be the space that *would* be minimally
required to store the first subtype. Note that in
some implementations this might well not correspond
to ANY actual stored variable, and thus the AI
requirement might actually clearly violate the IA.

Nevertheless this seemed a reasonable way of making
things compatible, and we will introduce an option in
GNAT to conform to the AI (it has to be an option,
because otherwise we have a nasty incompatibility
with the previous valid implementation). Of course if
you do not use a size clause, the GNAT implementation
is conforming to the IA (whereas the approach of
different sizes for different subtypes is always
"wrong").

Robert Dewar


Sent via Deja.com
http://www.deja.com/



  parent reply	other threads:[~2000-12-14  1:40 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-12-13 15:53 GNAT bug with respect to an Implementation Advise Jeff Creem
2000-12-13 19:56 ` Florian Weimer
2000-12-14  0:49   ` Randy Brukardt
2000-12-14  1:40 ` Robert Dewar [this message]
2000-12-14  2:40   ` Jeff Creem
2000-12-14 22:47     ` Randy Brukardt
2000-12-15 22:00       ` Randy Brukardt
replies disabled

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