comp.lang.ada
 help / color / mirror / Atom feed
From: kst@thomsoft.com (Keith Thompson)
Subject: Re: Rules for Representation of Subtypes
Date: 1996/09/26
Date: 1996-09-26T00:00:00+00:00	[thread overview]
Message-ID: <DyC5xn.K3L@thomsoft.com> (raw)
In-Reply-To: dewar.843570543@schonberg


In <dewar.843570543@schonberg> dewar@cs.nyu.edu (Robert Dewar) writes:
[...]
> This in fact is a place where Ada 95, somewhat accidentally, is incompatible
> with most Ada 83 implementations. What Ada 95 did was to specify things that
> are left unspecified in the Ada 83 reference manual, and to do it in a manner
> that was compatible with the Intermetrics compiler, but not most other Ada
> 83 compilers, so this is something to be on the watch for.
[...]
> Second, in Ada 95, the size of a subtype is required to be the minimum
> number of bits, so it is NOT AT ALL the case that a subtype has the same
> size as the first subtype. On the contrary, this would be an incorrect
> implementation.
> 
> For example, Natural'Size is required to be Integer'Size MINUS ONE, i.e.
> 31, not 32, on most machines. This can cause chaos if a program assumes
> that Natural'Size is 32, as it was on many Ada 83 implementations.

The Ada 83 reference manual's description of the 'Size attribute is
rather vague.  AI-00536 was an attempt to clarify this description.
Among other things, it says:

        If the size of a type or a subtype S has not been determined by
        a length clause and S is either a scalar subtype, a constrained
        array subtype, a constrained subtype with discriminants, an
        access type, a task type, or a private type whose full type is
        one of these types, then S'SIZE yields the smallest number of
        bits that an implementation will allocate for an object declared
        with the subtype indication S; objects whose size is determined
        by a record component clause are not considered in determining
        the value of S'SIZE.

        For the predefined type BOOLEAN, BOOLEAN'SIZE is one.

In other words, the 'Size for a subtype is the smallest size that can be
allocated for an object of that subtype, including standalone objects
and components of (possibly packed) arrays and records, but excluding
components affected by record component clauses.

For an Ada 83 implementation that can pack a Natural and a Boolean into
a single word in a packed record, Natural'Size should be Integer'Size - 1.

Note in particular that Boolean'Size was required to be one, even though
a standalone Boolean object is very likely to occupy 8 bits or more.

I seem to recall that this interpretation was enforced by the 1.11 ACVCs,
though I don't remember the exact details.

Of the two Ada 83 implementations I have access to, one uses
Natural'Size=31.  The other uses Natural'Size=32, but it doesn't support
pragma Pack on records.

(Publicly disputing Robert Dewar is always dangerous.  Fortunately it's
a bounded error; the effect is limited to learning something.)

-- 
Keith Thompson (The_Other_Keith) kst@thomsoft.com <*>
TeleSoft^H^H^H^H^H^H^H^H Alsys^H^H^H^H^H Thomson Software Products
10251 Vista Sorrento Parkway, Suite 300, San Diego, CA, USA, 92121-2706
FIJAGDWOL




  reply	other threads:[~1996-09-26  0:00 UTC|newest]

Thread overview: 92+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-09-22  0:00 Rules for Representation of Subtypes Matthew Heaney
1996-09-23  0:00 ` David C. Hoos, Sr.
1996-09-23  0:00   ` Robert A Duff
1996-09-23  0:00   ` Samuel T. Harris
1996-09-26  0:00     ` David C. Hoos, Sr.
1996-09-24  0:00   ` Robert Dewar
1996-09-26  0:00     ` Keith Thompson [this message]
1996-09-26  0:00       ` Matthew Heaney
1996-09-27  0:00         ` Robert Dewar
1996-09-27  0:00         ` Robert A Duff
1996-09-27  0:00           ` Robert Dewar
1996-09-27  0:00       ` Robert A Duff
1996-09-24  0:00   ` Robert Dewar
1996-09-23  0:00 ` Robert A Duff
1996-09-24  0:00   ` Matthew Heaney
1996-09-26  0:00     ` Robert A Duff
1996-09-26  0:00       ` Larry Kilgallen
1996-09-27  0:00         ` Robert A Duff
1996-09-27  0:00           ` Mark A Biggar
1996-09-30  0:00             ` Robert A Duff
1996-10-01  0:00               ` Larry Kilgallen
1996-10-01  0:00                 ` Samuel Tardieu
1996-10-01  0:00                   ` Ken Garlington
1996-10-01  0:00                   ` Valid Attribute and Unchecked Conversion Matthew Heaney
1996-10-02  0:00                     ` Robert A Duff
1996-10-04  0:00                       ` Keith Thompson
1996-10-04  0:00                         ` Robert A Duff
1996-10-04  0:00                           ` Robert Dewar
1996-10-11  0:00                             ` Norman H. Cohen
1996-10-12  0:00                               ` Robert Dewar
1996-10-06  0:00                           ` Keith Thompson
1996-10-07  0:00                             ` Robert Dewar
1996-10-09  0:00                               ` Keith Thompson
1996-10-07  0:00                           ` Ken Garlington
1996-10-08  0:00                           ` Alan Brain
1996-10-04  0:00                         ` Matthew Heaney
1996-10-07  0:00                           ` Robert Dewar
1996-10-09  0:00                             ` Keith Thompson
1996-10-07  0:00                         ` Robert Dewar
1996-10-10  0:00                           ` Ken Garlington
1996-10-11  0:00                             ` Robert Dewar
1996-10-14  0:00                               ` Ken Garlington
1996-10-14  0:00                               ` Keith Thompson
1996-10-07  0:00                         ` Kenneth Almquist
1996-10-01  0:00                 ` Rules for Representation of Subtypes Robert A Duff
1996-09-28  0:00           ` Larry Kilgallen
1996-09-29  0:00             ` Robert A Duff
1996-09-29  0:00               ` Larry Kilgallen
1996-09-29  0:00                 ` Matthew Heaney
1996-09-30  0:00                 ` Robert A Duff
1996-10-01  0:00                   ` Ken Garlington
1996-10-02  0:00                     ` Robert A Duff
1996-10-02  0:00                       ` Ken Garlington
1996-10-06  0:00                   ` Robert Dewar
1996-09-29  0:00               ` Matthew Heaney
1996-09-30  0:00                 ` Robert A Duff
1996-09-30  0:00                 ` Robert Dewar
1996-09-30  0:00                   ` Matthew Heaney
1996-10-03  0:00             ` Robert Dewar
1996-10-02  0:00         ` Valid Attribute and Unchecked Conversion George Haddad
1996-10-03  0:00           ` John Herro
1996-10-04  0:00             ` Karl Cooper {46901}
1996-10-07  0:00               ` Mark A Biggar
1996-10-08  0:00                 ` Robert Dewar
1996-10-05  0:00             ` Robert Dewar
1996-10-06  0:00               ` Keith Thompson
1996-10-14  0:00                 ` Robert A Duff
1996-10-02  0:00         ` Robert I. Eachus
1996-10-02  0:00           ` Matthew Heaney
1996-09-27  0:00       ` Rules for Representation of Subtypes Matthew Heaney
1996-09-27  0:00         ` Robert A Duff
  -- strict thread matches above, loose matches on Subject: below --
1996-09-28  0:00 Robert Dewar
1996-09-30  0:00 ` Keith Thompson
1996-09-28  0:00 Robert Dewar
1996-09-29  0:00 ` Robert A Duff
1996-09-29  0:00   ` Matthew Heaney
1996-09-29  0:00   ` Robert Dewar
1996-09-30  0:00     ` Art Schwarz
1996-09-30  0:00       ` Robert A Duff
1996-10-01  0:00       ` Larry Kilgallen
1996-10-01  0:00         ` Brian R. Hanson
1996-10-01  0:00         ` Robert A Duff
1996-09-28  0:00 Robert Dewar
1996-09-29  0:00 ` Robert A Duff
1996-09-29  0:00   ` Matthew Heaney
1996-10-02  0:00 Franco Mazzanti
1996-10-03  0:00 ` Robert A Duff
1996-10-03  0:00 Franco Mazzanti
1996-10-03  0:00 ` Robert A Duff
1996-10-10  0:00 W. Wesley Groleau (Wes)
1996-10-10  0:00 ` Robert Dewar
1996-10-11  0:00 ` Ken Garlington
replies disabled

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