From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.5-pre1 Date: 3 Sep 93 19:06:47 GMT From: dog.ee.lbl.gov!agate!spool.mu.edu!umn.edu!email.sp.paramax.com!not-for-ma il@ucbvax.Berkeley.EDU (Robert Parkhill) Subject: Re: Unchecked_Conversion question Message-ID: <2684k7$2hc@sun_tzu.sp.paramax.com> List-Id: adam@irvine.com (Adam Beneschan) writes: > In article <1993Sep1.154715.10498@Rapnet.Sanders.Lockheed.Com> lvonrude@Rapne t.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. We found that on our system we must always make explict legalty checks on the integer representations of data words/registers,etc (stuff gotten from non-ada, not this Ada program sources). The way the checks were made depended upon the often weird aspects of the external devices and how fast something had to be done. Robert Parkhill