1-- { dg-do compile } 2-- { dg-options "-O -gnatws" } 3 4with Unchecked_Conversion; 5 6package body Opt81 is 7 8 procedure Copy (From, To : Rec) is 9 Len : constant Natural := From.A.all'Length; 10 subtype Fixed_String is String (1 .. Len); 11 type Fixed_String_Access is access Fixed_String; 12 function To_Fixed is new 13 Unchecked_Conversion (Source => String_Access, 14 Target => Fixed_String_Access); 15 S : Fixed_String_Access := To_Fixed (To.A); 16 begin 17 S (1 .. Len) := From.A.all; 18 end; 19 20end Opt81; 21