with Ada.Text_IO; use Ada.Text_IO;
procedure Main is
   function Id (X : Integer) return Integer is (X);
   type Arr is array (Integer range <>) of Integer;
   subtype Arr4 is Arr (2 .. 5);
   --  one choice known only at run time: the aggregate's bounds are its own, and it
   --  slides into the target's (RM 4.3.3(26))
   A : constant Arr (1 .. 3) := (Id (11) .. Id (13) => 7);
   B : Arr (1 .. Id (3)) := (others => 0);
   C : constant Arr (1 .. Id (1)) := (Id (5) => 4);
   --  aggregates in a conditional expression take the target's bounds (RM 4.3.3(15.1))
   D : constant Arr4 := (if Id (2) > 4 then (1, 2, others => 5) else (others => 9));
   E : constant Arr4 := (case Id (3) is when 3 => (others => 6), when others => (1, 2, 3, 4));
   F : constant Arr (1 .. 4) := (if Id (1) = 1 then (1, 2, others => 8) else (others => 0));
begin
   B := (B'Range => 1);
   pragma Assert (A (1) = 7 and A (3) = 7 and A'First = 1);
   pragma Assert (B (1) = 1 and B (3) = 1);
   pragma Assert (C'First = 1 and C (1) = 4);
   pragma Assert (for all X of D => X = 9);
   pragma Assert (for all X of E => X = 6);
   pragma Assert (F (1) = 1 and F (2) = 2 and F (3) = 8 and F (4) = 8);
   Put_Line (Integer'Image (A (2)) & Integer'Image (B (2)) & Integer'Image (C (1)) & Integer'Image (D (5)) & Integer'Image (E (2)) & Integer'Image (F (4)));
end Main;
