--  Equality of records with an array under the max-size rule (`String (1 .. Len)` with room
--  for the longest): the components as long as the discriminant says, never the room past
--  it, which no value writes (C45271A, C45273A). Also through a record component, an array
--  of such records, and unconstrained objects that held a longer value first.
with Ada.Text_IO;
procedure Main is
   subtype Int is Integer range 1 .. 20;
   type Rec (Len : Int := 3) is record
      A : String (1 .. Len);
   end record;
   type Outer is record
      I : Integer;
      R : Rec (5);
   end record;
   type Arr is array (1 .. 2) of Rec (5);
   R3 : constant Rec (5) := (5, "WHERE");
   R4 : Rec (5) := (5, "WHERE");
   O1 : constant Outer := (1, (5, "WHERE"));
   O2 : Outer := (1, (5, "WHERE"));
   A1 : constant Arr := (others => (5, "WHERE"));
   A2 : Arr := (others => (5, "WHERE"));
   U1 : Rec := (8, "ABCDEFGH");
   U2 : Rec := (2, "AB");
begin
   U1 := (2, "AB");
   pragma Assert (R3 = R4 and O1 = O2 and A1 = A2 and U1 = U2);
   Ada.Text_IO.Put_Line (Boolean'Image (R3 = R4) & " " & Boolean'Image (O1 = O2) & " " & Boolean'Image (A1 = A2) & " " & Boolean'Image (U1 = U2));
   R4.A (5) := 'X';
   O2.R.A (5) := 'X';
   A2 (2).A (1) := 'X';
   U2 := (3, "ABC");
   pragma Assert (R3 /= R4 and O1 /= O2 and A1 /= A2 and U1 /= U2);
   Ada.Text_IO.Put_Line (Boolean'Image (R3 = R4) & " " & Boolean'Image (O1 = O2) & " " & Boolean'Image (A1 = A2) & " " & Boolean'Image (U1 = U2));
end Main;
