Always using the primary stack when concatenating arrays can lead to a very large stack usage. To alleviate this, if the current scope is already using the secondary stack, then allocate the temporary object on the secondary stack as well. For the time being, this is for string concatenation, since using it with e.g. controlled objects can lead to missing finalization and memory leaks. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch4.adb (Expand_Concatenate): Allocate result of string concatenation on secondary stack when relevant.