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=-0.8 required=5.0 tests=BAYES_00,INVALID_DATE autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,e258612d447226e4 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 1994-11-23 13:33:07 PST Path: nntp.gmd.de!newsserver.jvnc.net!howland.reston.ans.net!news.moneng.mei.com!hookup!olivea!barrnet.net!rational.com!kdm From: kdm@puppy.rational.com (Kent Mitchell) Newsgroups: comp.lang.ada Subject: Re: Range Check Query Date: 23 Nov 1994 17:31:32 GMT Organization: Rational Software Corporation Message-ID: <3avu9k$t02@rational.rational.com> References: <9411181527.AA08827@eurocontrol.de> NNTP-Posting-Host: puppy.rational.com X-Newsreader: TIN [version 1.2 PL2] Date: 1994-11-23T17:31:32+00:00 List-Id: Bob Wells #402 (wel@EUROCONTROL.DE) wrote: : type dn18906 is -- layout is for the 18906 message . : record : dnspare : integer range 0 .. 1; : dnspare2 : integer range 0 .. 3; : dnch1 : integer range 0 .. (2**7) - 1; : dnch2 : integer range 0 .. (2**7) - 1; : end record; : for dn18906 use : record at mod 1; : dnspare at 0 range 0 .. 1; : dnspare2 at 0 range 2 .. 7; : dnch1 at 0 range 8 .. 15; : dnch2 at 0 range 16 .. 23; : end record; : for dn18906'size use 24; : type Dn_189_Data is array(1 .. N_Data) of Dn18906; : pragma Pack(Dn_189_Data); : M_T : Dn_189_Data; : for M_T use at P_Mesg_Conv(P_Ohead) + 12; : P_Mesg_Conv is an Unchecked_Conversion of an access type to a : system address. The access type points to an incoming byte : stream. : OK, then in the body of this package we have: : if M_T(1).Dnspare = 2 then : -- do something : end if; : The incoming stream definitely has value of 2 occaisionaly in this : component yet it doesn't raise Constraint_Error? : Once again we are using the : Verdix Ada Compiler, Copyright 1984, 1992 : VADSworks for Sun-4 -> MC68020/30/vxWorks, (VADS 6.0.5) : Mon Aug 17 09:11:00 EST 1992 2.0.3(b) Hmmm ... this is an interesting program from a number of aspects. I don't think you'd get a constraint error because there never is a checked assignment. You will not get a range check from unchecked_conversion nor will you get a range check on the boolean expression (because it's not an assignment). The second interesting problem is that I'd never expect the true arm of the if to be taken as the compiler should have supressed this as dead code (of course that depends on the optomization level). I do see how it "could" take the arm if it's not supressed because the code *does* allocate 2 bits for the Dnspare field so a value of 2 *is* possible. To sum this all up, given a basically eronious program, anything is possible. -- Kent Mitchell | One possible reason that things aren't Technical Consultant | going according to plan is ..... Rational Software Corporation | that there never *was* a plan!