]> git.ipfire.org Git - thirdparty/gcc.git/commit
ada: Fix memory leak for unconstrained limited arrays in anonymous contexts
authorEric Botcazou <ebotcazou@adacore.com>
Tue, 11 Nov 2025 09:35:54 +0000 (10:35 +0100)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Fri, 21 Nov 2025 08:29:37 +0000 (09:29 +0100)
commit0c8271742f32fcf08f0b5818aaad2daafff89b62
treeb755913d10708c9e0758040668be90657b4bcbd3
parentf9ee1322a8297e2391e24b52f9f19028142e0b92
ada: Fix memory leak for unconstrained limited arrays in anonymous contexts

A change made a long time ago has introduced a leak of the secondary stack
at run time for unconstrained limited non-controlled arrays in anonymous
contexts, because of the lack of a transient scope in these contexts.

The large comment preceding the call to Establish_Transient_Scope in the
Resolve_Call procedure explains the strategy for build-in-place functions,
so the best course of action is probably to revert the commit and to fix
the original problem along the lines of the comment.

gcc/ada/ChangeLog:

* exp_ch3.adb (Expand_N_Object_Declaration): Delete ancient comment.
* exp_ch6.adb (Expand_Call_Helper): Do not establish a transient
scope for build-in-place functions in anonymous contexts here...
(Make_Build_In_Place_Call_In_Anonymous_Context): ...but here instead.
* sem_attr.adb (Resolve_Attribute) <Attribute_Range>: Remove obsolete
code dealing with transient scopes.
* sem_res.adb (Resolve_Actuals): Likewise.
(Resolve_Call): Adjust comment on the strategy for transient scopes.
gcc/ada/exp_ch3.adb
gcc/ada/exp_ch6.adb
gcc/ada/sem_attr.adb
gcc/ada/sem_res.adb