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,df40d0d1975a16a6 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-06-13 06:56:01 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!news-lond.gip.net!news.tele.dk!news.tele.dk!small.news.tele.dk!uninett.no!ntnu.no!not-for-mail From: Preben Randhol Newsgroups: comp.lang.ada Subject: Re: Optimizing Boundary Checks Date: Fri, 13 Jun 2003 13:56:01 +0000 (UTC) Organization: Norwegian university of science and technology Message-ID: References: <20030613140324.0000372e._elh_@_terma_._com_> NNTP-Posting-Host: kiuk0152.chembio.ntnu.no X-Trace: tyfon.itea.ntnu.no 1055512561 13121 129.241.83.78 (13 Jun 2003 13:56:01 GMT) X-Complaints-To: usenet@itea.ntnu.no NNTP-Posting-Date: Fri, 13 Jun 2003 13:56:01 +0000 (UTC) User-Agent: slrn/0.9.7.4 (Linux) Xref: archiver1.google.com comp.lang.ada:39115 Date: 2003-06-13T13:56:01+00:00 List-Id: Vinzent Hoefler wrote: > > But if you'd like to try > >|i : Integer; >| ... >|i := 11; >|Boxes (i) := 1; > > instead, then I guess, there will be no warning, because at the time > the code is compiled, "i" will *not* be replaced by the constant 11 > and the actual value of "i" is probably already out of scope for the > compiler (highly depends on the implementation, I think). Although, > any optimizing stage later probably still only generates a call to the > exception handler if it is smart enough. If it is not, then there must > be a range check here because So to sum up: If I had done: subtype Index_Range is Integer range 1 .. 10; type Items is array (Index_Range) of Natural; Boxes : Items; Index : Integer := 11; begin Boxes (Index) := 1; then I get an constraint error at run-time as the compiler will accept the code. And in this case range checks on the array must be on. If I change to: type Index_Range is range 1 .. 10; Then the range checks on the array *can* be switched off as the range checks of Index_Range will do. Is this right? I'm asking because there was an post some days ago saying that my example above could have range checks on the array off IIRC and that puzzels me. Preben -- Preben Randhol http://www.pvv.org/~randhol/