--  a record component passed for an `out String` keeps its bounds and gets the characters
--  written to it; a string literal is a component's default
with Ada.Text_IO;

procedure Main is
   type Rec is record
      Name : String (1 .. 4) := "    ";
      N : Natural := 0;
   end record;

   procedure Fill (Item : out String; Count : out Natural)
     with Always_Terminates, Pre => Item'Length = 4, Post => Count = 2
   is
   begin
      Item := "ab  ";
      Count := 2;
   end Fill;

   function Make return Rec is
   begin
      return Result : Rec do
         Fill (Result.Name, Result.N);
      end return;
   end Make;

   Plain : Rec;
   X : constant Rec := Make;
begin
   Ada.Text_IO.Put_Line ("[" & Plain.Name & "]" & Natural'Image (Plain.N));
   Ada.Text_IO.Put_Line ("[" & X.Name & "]" & Natural'Image (X.N));
end Main;
