comp.lang.ada
 help / color / mirror / Atom feed
* Interesting effects in array renaming
@ 2003-06-22 14:52 Dmitry A. Kazakov
  2003-06-22 17:24 ` Jeffrey Carter
  0 siblings, 1 reply; 20+ messages in thread
From: Dmitry A. Kazakov @ 2003-06-22 14:52 UTC (permalink / raw)


---------- 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?

I would expect either

1. XX'Range = Constrained'Range and indices are shifted

or

2. Raising Constraint_Error while renaming. How else could the compiler 
remove range checks for

X : Array_Subtype ...

for I in Array_Subtype'Range loop
   X (I) ...

-- 
Regards,
Dmitry A. Kazakov
www.dmitry-kazakov.de



^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2003-06-26 13:01 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-06-22 14:52 Interesting effects in array renaming Dmitry A. Kazakov
2003-06-22 17:24 ` Jeffrey Carter
2003-06-23  8:12   ` Dmitry A. Kazakov
2003-06-23 10:29     ` Georg Bauhaus
2003-06-23 11:37       ` Dmitry A. Kazakov
2003-06-23 13:28         ` Georg Bauhaus
2003-06-24  7:35           ` Dmitry A. Kazakov
2003-06-24 14:38             ` Georg Bauhaus
2003-06-25 10:28               ` Dmitry A. Kazakov
2003-06-25 14:23                 ` Georg Bauhaus
2003-06-25 19:00                   ` Dmitry A. Kazakov
2003-06-24  2:35     ` Robert I. Eachus
2003-06-24  7:35       ` Dmitry A. Kazakov
2003-06-24 10:08         ` Lutz Donnerhacke
2003-06-24 11:53         ` Georg Bauhaus
2003-06-24 12:48           ` Dmitry A. Kazakov
2003-06-26  2:54             ` Randy Brukardt
2003-06-26  6:27               ` Vinzent Hoefler
2003-06-26 12:44                 ` Georg Bauhaus
2003-06-26 13:01                   ` Vinzent Hoefler

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox