comp.lang.ada
 help / color / mirror / Atom feed
From: Ken Garlington <garlingtonke@lmtas.lmco.com>
Subject: Re: Rules for Representation of Subtypes
Date: 1996/10/11
Date: 1996-10-11T00:00:00+00:00	[thread overview]
Message-ID: <325E5259.6D3E@lmtas.lmco.com> (raw)
In-Reply-To: 9610101740.AA09737@most


W. Wesley Groleau (Wes) wrote:
> [snip]
> I haven't used Verdix in 18 months, but if I remember right, it allowed
> source to be larger than target WITH a warning.  Similar memory for
> VAX Ada, though I haven't used that in five years.  Unfortunately, many
> coders suppress warnings because "there are so @$#^$%^*&$ many of them,
> they just hide the real problems."

DEC Ada v3.2 still permits dissimilar sizes. Here's the code I tried:

with Unchecked_Conversion;
package UC_Pkg is

  type S_Type is range 0 .. 16#7FFF_FFFF#;
  for S_Type'Size use 32;

  type T_Type is range 0 .. 10;
  for T_Type'Size use 4;

  function S_to_T is new Unchecked_Conversion (S_Type, T_Type);

  S : S_Type := 16#FFFF#;
  T : T_Type;

end;

with UC_Pkg; use UC_Pkg;
with Text_IO;
procedure UC is
begin
  T := S_to_T(S);  -- examining T in the DEC debugger after this statement
                   -- shows T to be equal to 16#F#.

  Text_IO.Put_Line(T_Type'Image(T));  -- prints "-1" (16#F# as two's complement)
end;

In Ada 83, there's an AI that permits the unchecked conversion to be rejected,
but it's not required.

> 
> ---------------------------------------------------------------------------
> W. Wesley Groleau (Wes)                                Office: 219-429-4923
> Hughes Defense Communications (MS 10-40)                 Home: 219-471-7206
> Fort Wayne,  IN   46808                  (Unix): wwgrol@pseserv3.fw.hac.com
> ---------------------------------------------------------------------------

-- 
LMTAS - "Our Brand Means Quality"
For more info, see http://www.lmtas.com or http://www.lmco.com




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

Thread overview: 61+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-10-10  0:00 Rules for Representation of Subtypes W. Wesley Groleau (Wes)
1996-10-10  0:00 ` Robert Dewar
1996-10-11  0:00 ` Ken Garlington [this message]
  -- strict thread matches above, loose matches on Subject: below --
1996-10-03  0:00 Franco Mazzanti
1996-10-03  0:00 ` Robert A Duff
1996-10-02  0:00 Franco Mazzanti
1996-10-03  0:00 ` Robert A Duff
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-09-22  0:00 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
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                 ` Robert A Duff
1996-10-01  0:00                 ` Samuel Tardieu
1996-10-01  0:00                   ` Ken Garlington
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-09-27  0:00       ` Matthew Heaney
1996-09-27  0:00         ` Robert A Duff
replies disabled

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