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:40:04 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 14:38:33 +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 1055508002 18863619 213.200.246.247 (16 [175126]) X-Newsreader: Forte Agent 1.8/32.548 Xref: archiver1.google.com comp.lang.ada:39100 Date: 2003-06-13T14:38:33+02: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: >>=20 >> type Index_Range is range 1 .. 10; >> type Items is array (Index_Range) of Natural; >>=20 >> But if you write: >>=20 >> type Items is array (1 .. 10) of Natural; >>=20 >> 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. 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. OTOH, I think, using such unnamed indices is a quite bad idea anyway, because it breaks the type safety. So simply: Don't do it. :-) 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.