comp.lang.ada
 help / color / mirror / Atom feed
From: Robert Dewar <robert_dewar@my-deja.com>
Subject: Re: Porting Ada83 to Ada95 compiler/VxWorks
Date: 1999/11/12
Date: 1999-11-12T00:00:00+00:00	[thread overview]
Message-ID: <80h78f$nf7$1@nnrp1.deja.com> (raw)
In-Reply-To: 382B4F79.F8B31A68@averstar.com

In article <382B4F79.F8B31A68@averstar.com>,
  Tucker Taft <stt@averstar.com> wrote:
>    1) type Character now has 256 enumeration literals
>    2) library packages must *not* have a body ...
>    3) you need to decide in a generic ...


In our experience, much more important is

>    4) the meaning of 'Size has changed radically

In Ada 83, the meaning of 'Size was not completely well
specified but in practice, was very uniformly implemented.
In particular, sizes of subtypes generally matched sizes
of the base types, so for example, Natural'Size was the
same as Integer'Size, typically 32. As far as I know, the
only Ada 83 compiler implementing something different was
the very rarely used Intermetrics compiler for the IBM
mainframe, but I am happy to be corrected on this if someone
knows some other compiler ...

In Ada 95, an attempt was made to define 'Size more precisely
(a good thing), but the choice made, though formally consistent
with the lack of specification in the Ada 83 RM, was to insist
that Natural'Size be 31 (a very bad thing). This actually
violates one of the requirements in the Ada 95 requirements not
to introduce incompatibilities with existing practice, but
unfortunately this did not get fixed in the revision process.

What this means is that a declaration like

  type x is record
    A : Natural;
    B : Character;
  end record;

  for x use record
    A at 0 range 0 .. Natural'Size - 1;
    B at 0 range 0 .. Natural'Size .. Natural'Size + 7;
  end record;

has radically different semantics in typical Ada 83 compilers
and Ada 95.

Yes, from a formal point of view this is indeed in Tuck's
category of implementation dependent code, but that is really
a formalism. In practice this was a definitely incompatible
mistake in the Ada 95 design, and is something to watch out
for. Similarly suprising is:

   type x is array (1 .. 10) of Natural;
   pragma Pack (x);

In an Ada 83 compiler, this would never pack to 31 bits, since
Natural'Size is 32 bits, but in Ada 95 compilers it may pack to
31 bits causing porting problems.

This has been one of the biggest porting headaches that I would
really put in the category of incompatible changes, rather than
ill-advised or ill-understood implementation dependent code
(indeed the record rep clause above is clearly a concientious
attempt to AVOID being implementation dependent).



Sent via Deja.com http://www.deja.com/
Before you buy.




      reply	other threads:[~1999-11-12  0:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <WwUrOHl=X34bBwX3FQ9rGRBeoTm0@4ax.com>
1999-11-11  0:00 ` Porting Ada83 to Ada95 compiler/VxWorks Tucker Taft
1999-11-12  0:00   ` Robert Dewar [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