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:48:39 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!bloom-beacon.mit.edu!news-out.cwix.com!newsfeed.cwix.com!newsfeed.icl.net!newsfeed.fjserv.net!news.algonet.se!algonet!newsfeed1!bredband!uio.no!uninett.no!ntnu.no!not-for-mail From: Preben Randhol Newsgroups: comp.lang.ada Subject: Re: Optimizing Boundary Checks Date: Fri, 13 Jun 2003 12:48:38 +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 1055508518 11284 129.241.83.78 (13 Jun 2003 12:48:38 GMT) X-Complaints-To: usenet@itea.ntnu.no NNTP-Posting-Date: Fri, 13 Jun 2003 12:48:38 +0000 (UTC) User-Agent: slrn/0.9.7.4 (Linux) Xref: archiver1.google.com comp.lang.ada:39104 Date: 2003-06-13T12:48:38+00:00 List-Id: Preben Randhol wrote: > 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? Reason for asking is that I get: t.adb:10:11: warning: value not in range of subtype of "Standard.integer" defined at line 6 t.adb:10:11: warning: "constraint_error" will be raised at run time if I do: type Items is array (1 .. 10) of Natural; Boxes : Items; begin Boxes(11) := 1; -- Preben Randhol http://www.pvv.org/~randhol/