--  Arrays whose component subtype has bounds known only at run time (RM 3.6(10),
--  4.3.3(30)): each component takes the subtype's bounds, a value going to one is as long
--  and slides into them, in code each component's own storage (D257).
with Ada.Text_IO; use Ada.Text_IO;
procedure Main is
   function Ident (X : Integer) return Integer is (X);
   type Row is array (1 .. 2) of String (Ident (3) .. 5);
   subtype Sk is Integer range 2 .. 6;
   type Base is array (Sk range <>) of Integer;
   subtype Te1 is Base (Ident (3) .. 5);
   type Te2 is array (1 .. 2) of Te1;
   type Holder is record
      R : Row;
      N : Integer;
   end record;
   function Made (S : String) return Row is (others => S) with Pre => S'Length = 3;
   procedure Show (S : String) is
   begin
      Put_Line (S & Integer'Image (S'First) & Integer'Image (S'Last));
   end Show;
   E : Row;
   F : constant Row := (others => "QRS");
   G : Te2;
   H : Holder := (R => ("one", "two"), N => 2);
   A1 : array (Boolean, Integer range Ident (1) .. Ident (3)) of String (Ident (5) .. Ident (7));
begin
   E := (1 .. 2 => "ABC");
   pragma Assert (E (1)'First = 3 and E (2)'Last = 5 and E (1) = "ABC");
   Show (E (1));
   E (2) := "XYZ";
   Show (E (2));
   Show (F (1));
   E := F;
   Show (E (2));
   E := ("abc", "def");
   Show (E (1));
   Show (E (2));
   pragma Assert (E /= F);
   G := (1 .. 2 => (3, 2, 1));
   pragma Assert (G (1)'First = 3 and G (2) (5) = 1);
   Put_Line (Integer'Image (G (2) (3)));
   Show (H.R (2));
   H.R (1) := E (2);
   Show (H.R (1));
   E := Made ("mno");
   Show (E (1));
   A1 (True, 2) := "uvw";
   pragma Assert (A1 (True, 2)'First = 5 and A1 (True, 2) = "uvw");
   Show (A1 (True, 2));
end Main;
