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:29:35 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!headwall.stanford.edu!fu-berlin.de!uni-berlin.de!213.200.246.247!not-for-mail From: Vinzent Hoefler Newsgroups: comp.lang.ada Subject: Re: Optimizing Boundary Checks Date: Fri, 13 Jun 2003 15:28:06 +0200 Organization: JeLlyFish software Message-ID: References: <20030613140324.0000372e._elh_@_terma_._com_> NNTP-Posting-Host: 213.200.246.247 Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable X-Trace: fu-berlin.de 1055510974 18747682 213.200.246.247 (16 [175126]) X-Newsreader: Forte Agent 1.8/32.548 Xref: archiver1.google.com comp.lang.ada:39106 Date: 2003-06-13T15:28:06+02:00 List-Id: Preben Randhol wrote: >Vinzent Hoefler wrote: >>=20 >> Well, the compiler *could* see that the type Index_Range always >> satisfies the same constraint as for the array. I don't know for sure, >> but I'd think, it does, because somehow it must store the constraints >> for any type anyway and I strongly doubt that an optimizer would work >> on type names instead of actual numbers describing their constraints. > >For the second example I was thinking that the Index_Range was not >defined at all. Well, I guess, it's the same, it depends on what you code, I'd say. If you say |for i in 1 .. 10 loop | foo(i) :=3D ... and foo's index constraint is 1 .. 10, too, then the compiler/optimizer *might* detect it doesn't need a range check here. In cases where the actual value cannot be (easily) determined at compiler time, the compiler is required to generate a range check. Say, we call some function that returns an Integer, it is not easily determinable that the function always returns values in bounds (obviously, the contract doesn't tell us that here). So the compiler generates a range check here, of course. Just see my other posting. :) Vinzent. --=20 Parents strongly cautioned -- this posting is intended for mature audiences over 18. It may contain some material that many parents would not find suitable for children and may include intense violence, sexual situations, coarse language and suggestive dialogue.