comp.lang.ada
 help / color / mirror / Atom feed
From: dog.ee.lbl.gov!agate!howland.reston.ans.net!spool.mu.edu!sdd.hp.com!netwo rk.ucsd.edu!news.cerf.net!shrike.irvine.com!adam@ucbvax.Berkeley.EDU  (Adam Ben
Subject: Re: Unchecked_Conversion question
Date: 3 Sep 93 19:51:51 GMT	[thread overview]
Message-ID: <CCsn6F.GAL@irvine.com> (raw)

In article <2684k7$2hc@sun_tzu.sp.paramax.com> parkhill@sun_tzu.sp.paramax.com 
(Robert Parkhill) writes:

>   adam@irvine.com (Adam Beneschan) writes:
>   > In article <1993Sep1.154715.10498@Rapnet.Sanders.Lockheed.Com> lvonrude@R
apnet.Sanders.Lockheed.Com (Lowell S. VonRuden x5294) writes:
>   > 
>   > Anyway, if you want a more dependable version, try this:
>   > 
>     -- Deleted text
>   > 
>   >     if Int not in Enum_Low .. Enum_High then
>   >       raise Constraint_Error;   -- or whatever
>   >     end if;
>   >     E := Convert (Int);  
>   > 
>   >   end Sample;
>
>
>   I would not count on this being dependable, please refer to Tucker
>   Taft's post.  I can tell you that people I have worked with tried
>   this with the TeleSoft Ada compiler and found there code optimized
>   away.  The compiler assumed that anything it does is correct and
>   therefore it need not check for things that are obviously true. ;)
>
>   To it asking whether an enum was between the first legal value
>   and the last legal value was like asking if an integer object
>   had a value between integer'First and integer'Last.  The answer
>   was always yes. 

Yes, that was my point exactly.  Which is why I DIDN'T ask whether an
enumeration was between the first legal value and the last legal value.  In
my example above, Int is still an integer;  it hasn't been converted
to an enumeration yet.  My point, and Tucker's also, was that the
checking should be done on the *integer* before it's converted.

                                -- Adam

             reply	other threads:[~1993-09-03 19:51 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1993-09-03 19:51 dog.ee.lbl.gov!agate!howland.reston.ans.net!spool.mu.edu!sdd.hp.com!netwo [this message]
  -- strict thread matches above, loose matches on Subject: below --
1993-09-04  0:13 Unchecked_Conversion question Robert Dewar
1993-09-03 21:55 Robert Parkhill
1993-09-03 20:14 Wes Groleau x1240 C73-8
1993-09-03 19:06 dog.ee.lbl.gov!agate!spool.mu.edu!umn.edu!email.sp.paramax.com!not-for-ma
1993-09-02 15:43 dog.ee.lbl.gov!overload.lbl.gov!agate!howland.reston.ans.net!noc.near.net
1993-09-02 13:38 Lowell S. VonRuden x5294
1993-09-02  3:00 Robert Dewar
1993-09-01 16:43 dog.ee.lbl.gov!network.ucsd.edu!news.cerf.net!shrike.irvine.com!adam
1993-09-01 15:47 Lowell S. VonRuden x5294
replies disabled

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