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:30:47 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!cyclone.bc.net!in.100proofnews.com!in.100proofnews.com!fu-berlin.de!uni-berlin.de!62.173.119.178!not-for-mail From: Peter Amey Newsgroups: comp.lang.ada Subject: Re: Optimizing Boundary Checks Date: Fri, 13 Jun 2003 14:33:39 +0100 Message-ID: <3EE9D2B3.5050406@praxis-cs.co.uk> References: <20030613140324.0000372e._elh_@_terma_._com_> NNTP-Posting-Host: 62.173.119.178 Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Trace: fu-berlin.de 1055511046 18617704 62.173.119.178 (16 [69815]) User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.0.2) Gecko/20030208 Netscape/7.02 X-Accept-Language: en-us, en Xref: archiver1.google.com comp.lang.ada:39108 Date: 2003-06-13T14:33:39+01:00 List-Id: [snip] >> >>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; > > Your array declaration declares an index subtype just as if you had done so explicitly with subtype ItemRange is Integer range 1 ..10; type Items is array (ItemRange) of Natural; The array index in your "Boxes..." statement must be in the array index subtype and Gnat correctly reports that it isn't. Gnat can't tell you the name of the subtype because you didn't give it one! This is another reason why it is best to avoid use of anonymous types. Peter