--  A component without a default expression of its own still takes its subtype's default
--  (RM 3.3.1(18)): `J : Rec2 (D => H.D)` has H.D (ACATS C37102B; it was any value, so 0),
--  and a component of a record type with defaulted discriminants takes their defaults and
--  its components' defaults (C37009A; its array failed an index check).
with Ada.Text_IO;
procedure Main is
   function F (D : Integer) return Integer is (D);
   type Rec2 (D : Integer := 3) is record
      null;
   end record;
   H : constant Rec2 := (D => F (5));
   type Q (D : Integer := 0) is record
      J : Rec2 (D => H.D);
   end record;
   R : Q;
   subtype Small is Integer range 1 .. 10;
   type List is array (Integer range <>) of Integer;
   type Holder (P : Small := 2) is record
      A : List (1 .. P) := (1 .. P => 7);
   end record;
   type Outer is record
      U : Holder;
   end record;
   O : Outer;
begin
   Ada.Text_IO.Put_Line (Integer'Image (R.J.D));
   Ada.Text_IO.Put_Line (Integer'Image (O.U.P) & Integer'Image (O.U.A'Last) & Integer'Image (O.U.A (2)));
end Main;
