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,af3dada69080e420 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-06-22 10:26:40 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!headwall.stanford.edu!newshub.sdsu.edu!elnk-pas-nf2!newsfeed.earthlink.net!stamper.news.pas.earthlink.net!newsread1.prod.itd.earthlink.net.POSTED!not-for-mail Message-ID: <3EF5E6B8.3030203@spam.com> From: Jeffrey Carter Organization: jrcarter commercial-at acm [period | full stop] org User-Agent: Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.0.0) Gecko/20020530 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Interesting effects in array renaming References: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Date: Sun, 22 Jun 2003 17:24:17 GMT NNTP-Posting-Host: 63.184.32.54 X-Complaints-To: abuse@earthlink.net X-Trace: newsread1.prod.itd.earthlink.net 1056302657 63.184.32.54 (Sun, 22 Jun 2003 10:24:17 PDT) NNTP-Posting-Date: Sun, 22 Jun 2003 10:24:17 PDT Xref: archiver1.google.com comp.lang.ada:39569 Date: 2003-06-22T17:24:17+00:00 List-Id: Dmitry A. Kazakov wrote: > ---------- test.adb > with Ada.Text_IO; use Ada.Text_IO; > > procedure Test is > type Some_Array is array (Integer range <>) of Integer; > > procedure Foo (X : Some_Array) is > subtype Constrained is Some_Array (1..X'Length); > XX : Constrained renames X; > begin > Put_Line > ( "XX'Range:" > & Integer'Image (XX'First) > & ".." > & Integer'Image (XX'Last) > & ", Constrained'Range:" > & Integer'Image (Constrained'First) > & ".." > & Integer'Image (Constrained'Last) > ); > end Foo; > > Object : Some_Array (-3..2) := (-3, -2, -1, 0, 1, 2); > begin > Foo (Object); > end Test; > ---------- test.adb > > Surprisingly the above produces different ranges for XX and its declared > subtype. Isn't something wrong here? Note that you can also do subtype Constrained is Some_Array (1..X'Length-1); or subtype Constrained is Some_Array (1..3); with similar results. You can also do XX : Some_Array renames X; which perhaps demonstrates more clearly where the object's subtype comes from. -- Jeff Carter "English bed-wetting types." Monty Python & the Holy Grail