From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,dc82506adceed418 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-03-14 04:24:43 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!cyclone.bc.net!arclight.uoregon.edu!wn13feed!worldnet.att.net!204.127.198.203!attbi_feed3!attbi.com!rwcrnsc52.ops.asp.att.net.POSTED!not-for-mail From: "Jeffrey Creem" Newsgroups: comp.lang.ada References: <1b585154.0303140406.124c3312@posting.google.com> Subject: Re: Test for > 'last X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 Message-ID: <0Sjca.93610$sf5.60661@rwcrnsc52.ops.asp.att.net> NNTP-Posting-Host: 66.31.5.146 X-Complaints-To: abuse@attbi.com X-Trace: rwcrnsc52.ops.asp.att.net 1047644668 66.31.5.146 (Fri, 14 Mar 2003 12:24:28 GMT) NNTP-Posting-Date: Fri, 14 Mar 2003 12:24:28 GMT Organization: AT&T Broadband Date: Fri, 14 Mar 2003 12:24:28 GMT Xref: archiver1.google.com comp.lang.ada:35319 Date: 2003-03-14T12:24:28+00:00 List-Id: Someplace between mostly wrong and grossly wrong but likely to be just optimized away. (Unless enum_input is a variable of a base type that enum_type is a subtype of in which case this could be valid...but I doubt it). In any case, in Ada 83, there was no 'valid so people were often temped to write stuff like this..Note that if data got into enum_input via something like text_io.enumeration_io then this is incorrect but totally harmless code. If it got there via some unchecked_conversion or similar approach and there are not already other reasons why the data must be valid, then this is not sufficient to detect bad input. Note that just because it is technically wrong does not mean that if this code were run with checks suppressed that it would not accomplish what was desired....It is just that if it did accomplish what was desired, it is only due to relying on behaviour that is not required by the LRM. 13.9.1 Data Validity Bounded (Run-Time) Errors If the representation of a scalar object does not represent a value of the object's subtype (perhaps because the object was not initialized), the object is said to have an invalid representation. It is a bounded error to evaluate the value of such an object. If the error is detected, either Constraint_Error or Program_Error is raised. Otherwise, execution continues using the invalid representation. The rules of the language outside this subclause assume that all objects have valid representations. The semantics of operations on invalid representations are as follows: If the representation of the object represents a value of the object's type, the value of the type is used. If the representation of the object does not represent a value of the object's type, the semantics of operations on such representations is implementation-defined, but does not by itself lead to erroneous or unpredictable execution, or to other objects becoming abnormal. "Peter Richtmyer" wrote in message news:1b585154.0303140406.124c3312@posting.google.com... > This may be trivial, but I have come across some code > in a (weapon control) system that does checks similar > to: > > --------------------------------------- > if enum_input < enum_type'first or > enum_input > enum_type'last then > -- handle the input error > --------------------------------------- >