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,FREEMAIL_FROM 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 10:12:56 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!fu-berlin.de!uni-berlin.de!firewall.mdc-dayton.COM!not-for-mail From: Vinzent Hoefler Newsgroups: comp.lang.ada Subject: Re: Test for > 'last Date: Fri, 14 Mar 2003 13:10:58 -0500 Organization: JeLlyFish software Message-ID: References: <1b585154.0303140406.124c3312@posting.google.com> <3e721008$0$895$9b0f33e3@clyde> NNTP-Posting-Host: firewall.mdc-dayton.com (12.161.103.180) Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable X-Trace: fu-berlin.de 1047665573 70047511 12.161.103.180 (16 [175126]) X-Newsreader: Forte Agent 1.8/32.548 Xref: archiver1.google.com comp.lang.ada:35334 Date: 2003-03-14T13:10:58-05:00 List-Id: "Ant" wrote: >"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 >> --------------------------------------- > >[...] > >> But I am wondering whether people think the original code >> is OK, sort of wrong, really grossly wrong, or what. > >I would rather do this: > >if enum_input not in enum_type'first .. enum_type'last then > -- handle error >end if; And would be wrong, too, if enum_input also has the type enum_type. If you look closer to this, this statement does not make sense and the compiler is indeed not required to check this, because the contract tells him, this condition will *always* be false (even if in fact it might not be). What else should a enum_input contain than some value of enum_type? Either use 'Valid or use a type that is allowed to contain values outside the range of the type to be compared with. Vinzent.