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 05:42:53 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!headwall.stanford.edu!newshub.sdsu.edu!logbridge.uoregon.edu!newsfeed.vmunix.org!uio.no!ntnu.no!not-for-mail From: Preben Randhol Newsgroups: comp.lang.ada Subject: Re: Optimizing Boundary Checks Date: Fri, 13 Jun 2003 12:42:52 +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 1055508172 11284 129.241.83.78 (13 Jun 2003 12:42:52 GMT) X-Complaints-To: usenet@itea.ntnu.no NNTP-Posting-Date: Fri, 13 Jun 2003 12:42:52 +0000 (UTC) User-Agent: slrn/0.9.7.4 (Linux) Xref: archiver1.google.com comp.lang.ada:39101 Date: 2003-06-13T12:42:52+00:00 List-Id: Erlo Haugen wrote: > On Fri, 13 Jun 2003 11:49:03 +0000 (UTC) > Preben Randhol wrote: > >> After reading some posts here lately I have understood that the compiler >> can optimise out boundary checks on say arrays if you do this: >> >> type Index_Range is range 1 .. 10; >> type Items is array (Index_Range) of Natural; >> >> But if you write: >> >> type Items is array (1 .. 10) of Natural; >> >> is boundary checks then on? > > Yes, but in this case (principally) every acces to the array has to be > checked, whereas in the former case, the index is guaranteed to be > within range. I see. This is because the boundary checks are on the Index_Range type and thus one do not need them on Items too. How is it if Index_Range was defined as a subtype of Integer? -- Preben Randhol http://www.pvv.org/~randhol/