https://gcc.gnu.org/g:afb644eed3ccb5627645fe9060388a89fc6f8c3f
commit r16-1937-gafb644eed3ccb5627645fe9060388a89fc6f8c3f Author: Ronan Desplanques <desplanq...@adacore.com> Date: Thu Jun 5 09:48:22 2025 +0200 ada: Fix crash with Finalizable in corner case Since the introduction of the Finalizable aspect, there can be types for which Is_Controlled returns True but that don't have all three finalization primitives. The Generate_Finalization_Actions raised an exception in that case before this patch, which fixes the problem. gcc/ada/ChangeLog: * exp_aggr.adb (Generate_Finalization_Actions): Stop assuming that initialize primitive exists. Diff: --- gcc/ada/exp_aggr.adb | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/gcc/ada/exp_aggr.adb b/gcc/ada/exp_aggr.adb index fcf57bf9c31c..9ff69ec81301 100644 --- a/gcc/ada/exp_aggr.adb +++ b/gcc/ada/exp_aggr.adb @@ -2570,12 +2570,21 @@ package body Exp_Aggr is Ref := Convert_To (Init_Typ, New_Copy_Tree (Target)); Set_Assignment_OK (Ref); - Append_To (L, - Make_Procedure_Call_Statement (Loc, - Name => - New_Occurrence_Of - (Find_Controlled_Prim_Op (Init_Typ, Name_Initialize), Loc), - Parameter_Associations => New_List (New_Copy_Tree (Ref)))); + declare + Intlz : constant Entity_Id := + Find_Controlled_Prim_Op (Init_Typ, Name_Initialize); + begin + if Present (Intlz) then + Append_To + (L, + Make_Procedure_Call_Statement + (Loc, + Name => + New_Occurrence_Of (Intlz, Loc), + Parameter_Associations => + New_List (New_Copy_Tree (Ref)))); + end if; + end; end if; end Generate_Finalization_Actions;