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,36d61bbd5bb05d97,start X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-10-10 12:05:49 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!nntp-relay.ihug.net!ihug.co.nz!bnewspeer01.bru.ops.eu.uu.net!auucp0.ams.ops.eu.uu.net!bnewsifeed00.bru.ops.eu.uu.net!bnewspost00.bru.ops.eu.uu.net!emea.uu.net!read.news.be.uu.net!not-for-mail Message-ID: <3DA5CF6D.C703306F@cadence.com> Date: Thu, 10 Oct 2002 15:05:17 -0400 From: Paul Graham Organization: Cadence Design Systems X-Mailer: Mozilla 4.76 [en] (X11; U; SunOS 5.5.1 sun4u) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Question about subtype of loop index variable Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Original-NNTP-Posting-Host: pgraham-dsl.cadence.com X-Original-Trace: 10 Oct 2002 12:05:14 -0700, pgraham-dsl.cadence.com NNTP-Posting-Host: nntp-feed.Cadence.COM X-Trace: 1034276723 read.news.be.uu.net 7114 158.140.3.3 X-Complaints-To: abuse@be.uu.net Xref: archiver1.google.com comp.lang.ada:29684 Date: 2002-10-10T15:05:17-04:00 List-Id: I have a question about the type and subtype of a loop index variable. I'll just give an example: with Text_Io; use Text_Io; procedure Test_Range is package Int_Io is new Integer_Io(Integer); use Int_Io; type T1 is range 0 .. 7; type T2 is array(T1 range <>) of Integer; X : T2(0 .. 3); Y : Integer; begin Y := 0; for I in X'First - 1 .. X'Last + 1 loop Y := Y + 1; end loop; Put("Y = "); Put(Y); New_Line; end; My question is, what is the type (and subtype) of loop index I? Since the expressions X'First - 1 and X'Last + 1 are of type T1, then I is also of type T1. But the values X'First - 1 and X'Last + 1 lie outside the bounds of T1, so I would think that a range constraint error would occur as I is assigned these values. Yet gnat 3.13 compiles and executes this code without error. Am I misunderstanding something? Paul