String concatenation can be implemented either in-line or out-of-line by the compiler, depending on the optimization level and other factors. But doing in-line concatenation at library level is undesirable in general and the compiler already avoids it for simple declarations: S : String := S1 & S2; -- out-of-line at all optimization levels but not for slightly more complex ones: S : String := Ada.Characters.Handling.To_Upper (S1 & S2); which are implemented in-line for -O1 and above. This patch changes the second case to using out-of-line concatenation at all optimization levels which, among other things, generates more compact code. The following package must always use out-of-line concatenation: with Ada.Characters.Handling; package P is Scope: constant String := Ada.Characters.Handling.To_Upper ("P"); function Full_String return String; end P; package body P is Full_Scope : constant String := Ada.Characters.Handling.To_Upper (Scope & ".body"); function Full_String return String is (Full_Scope); end P; Tested on x86_64-pc-linux-gnu, committed on trunk 2017-04-25 Eric Botcazou * exp_ch4.adb (Library_Level_Target): New function. (Expand_Concatenate): When optimization is enabled, also expand the operation out-of-line if the concatenation is present within the expression of the declaration of a library-level object and not only if it is the expression of the declaration.