https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55725
--- Comment #5 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Marc Poulhi?s <d...@gcc.gnu.org>: https://gcc.gnu.org/g:bb4a081156175cf7ac7a818c6a669d3f63ea0ad8 commit r15-5151-gbb4a081156175cf7ac7a818c6a669d3f63ea0ad8 Author: Eric Botcazou <ebotca...@adacore.com> Date: Mon Oct 28 08:33:49 2024 +0100 ada: Fix premature finalization of anonymous access result from library function In GNAT's implementation, the finalization of controlled objects created through anonymous access types occurs when the enclosing library unit goes out of scope if this is safe, and never occurs otherwise. The case of a function that is a library unit with an anonymous access result type falls in the second category for the anonymous access result type itself and, therefore, finalization cannot take place for it. gcc/ada/ChangeLog: PR ada/55725 * exp_ch6.adb (Add_Collection_Actual_To_Build_In_Place_Call): Be prepared for no collection if the access type is anonymous. * exp_ch7.adb (Build_Anonymous_Collection): Return early for the anonymous access result type of a library function.