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:46:09 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news.uchicago.edu!newsfeed.cs.wisc.edu!144.212.100.101.MISMATCH!newsfeed!lon-transit.news.telstra.net!news.telstra.net!news-server.bigpond.net.au!not-for-mail From: Dale Stanbrough Newsgroups: comp.lang.ada Subject: Re: Optimizing Boundary Checks References: User-Agent: MT-NewsWatcher/3.3b1 (PPC Mac OS X) Message-ID: Date: Fri, 13 Jun 2003 13:45:45 GMT NNTP-Posting-Host: 144.132.47.50 X-Complaints-To: abuse@bigpond.net.au X-Trace: news-server.bigpond.net.au 1055511945 144.132.47.50 (Fri, 13 Jun 2003 23:45:45 EST) NNTP-Posting-Date: Fri, 13 Jun 2003 23:45:45 EST Organization: BigPond Internet Services (http://www.bigpond.net.au) Xref: archiver1.google.com comp.lang.ada:39112 Date: 2003-06-13T13:45:45+00:00 List-Id: 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? There are no boundary checks for a type declaration of course, so the question is "in which situations would a check be generated" Clearly this depends on the compiler, and the code. For example the code x : Items; for i in x'range loop put (x (i)); end loop; is quite easy for a compiler to know that no checks are needed. There are increasingly more difficult levels of analysis for the compiler depending on the situation. Dale