This patch removes a spurious initialization on the string that builds the name of task that is a record component, when Initialize_Scalars is enabled. This is both efficient, and prevents anomalies in the handling of dynamic objects on the secondary stack, that would result in a mangled name for such a task.
The following commands: gnatmake -q -O1 p.adb p must yield: where.container.a_tt_0000000100800E00 --- with Alloc; procedure P is begin Alloc.Alloc_One (1); end; --- package Alloc is procedure Alloc_One (Index : Integer); end; --- with CC; use CC; package body Alloc is type Container_Pointer is access all Container; type Container_With_Ref_Count_Type is record Container : Container_Pointer; Ref_Count : Natural; end record; Containers : array (1 .. 3) of Container_With_Ref_Count_Type := (others => (null, 0)); procedure Alloc_One (Index : Integer) is Where : Container_With_Ref_Count_Type renames Containers (Index); begin Where.Container := new Container; end; end; --- with Ada.Task_Identification; use Ada.Task_Identification; with Ada.Text_IO; use Ada.Text_IO; package body CC is task body TT is begin Put_Line (Image (Current_Task)); delay 1.0; end; end; --- package CC is type Container; task type TT (C : not null access Container); type Container is limited record A_TT : TT (Container'Access); end record; end; --- pragma Initialize_Scalars; --- Tested on x86_64-pc-linux-gnu, committed on trunk 2014-01-29 Ed Schonberg <schonb...@adacore.com> * exp_util.adb (Build_Task_Image_Prefix): Indicate that the resulting string is an internal entity. and thus requires no initialization. This is relevant when Initialize_ Scalars is enabled, because the resultant spurious initialization may lead to secondary stack anomalies that produce a mangled name for a task.
Index: exp_util.adb =================================================================== --- exp_util.adb (revision 207241) +++ exp_util.adb (working copy) @@ -1403,6 +1403,12 @@ Low_Bound => Make_Integer_Literal (Loc, 1), High_Bound => New_Occurrence_Of (Len, Loc))))))); + -- Indicate that the result is an internal temporary, so it does not + -- receive a bogus initialization when declaration is expanded. This + -- is both efficient, and prevents anomalies in the handling of + -- dynamic objects on the secondary stack. + + Set_Is_Internal (Res); Pos := Make_Temporary (Loc, 'P'); Append_To (Decls,