aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorBob Duff <duff@adacore.com>2020-10-23 17:27:34 -0400
committerPierre-Marie de Rodat <derodat@adacore.com>2020-11-26 03:39:49 -0500
commit0ea529086e7c36cd12bf8ff5a6187c9d8b2796a8 (patch)
treee93d3b173ec561017f95a6c082c015232bd1fdd1 /gcc
parenta160b4e046d11b51cbedb936b13d15e3d0b19f7e (diff)
downloadgcc-0ea529086e7c36cd12bf8ff5a6187c9d8b2796a8.zip
gcc-0ea529086e7c36cd12bf8ff5a6187c9d8b2796a8.tar.gz
gcc-0ea529086e7c36cd12bf8ff5a6187c9d8b2796a8.tar.bz2
[Ada] Memory leak in concatenation with Initialize_Scalars
gcc/ada/ * exp_ch4.adb (Expand_Concatenate): Call Set_No_Initialization on the N_Allocator node that is supposed to allocate on the secondary stack.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/exp_ch4.adb9
1 files changed, 9 insertions, 0 deletions
diff --git a/gcc/ada/exp_ch4.adb b/gcc/ada/exp_ch4.adb
index 6899e62..e0a62be 100644
--- a/gcc/ada/exp_ch4.adb
+++ b/gcc/ada/exp_ch4.adb
@@ -3505,8 +3505,17 @@ package body Exp_Ch4 is
Alloc :=
Make_Allocator (Loc,
Expression => New_Occurrence_Of (ConstrT, Loc));
+
+ -- Allocate on the secondary stack. This is currently done
+ -- only for type String, which normally doesn't have default
+ -- initialization, but we need to Set_No_Initialization in case
+ -- of Initialize_Scalars or Normalize_Scalars; otherwise, the
+ -- allocator will get transformed and will not use the secondary
+ -- stack.
+
Set_Storage_Pool (Alloc, RTE (RE_SS_Pool));
Set_Procedure_To_Call (Alloc, RTE (RE_SS_Allocate));
+ Set_No_Initialization (Alloc);
Temp := Make_Temporary (Loc, 'R', Alloc);
Insert_Action (Cnode,