https://gcc.gnu.org/g:11e06dd243ac578f81d435ca0aea2ce3340a0650
commit r15-4653-g11e06dd243ac578f81d435ca0aea2ce3340a0650 Author: Eric Botcazou <ebotca...@adacore.com> Date: Wed Sep 18 08:24:32 2024 +0200 ada: Fix fallout of change in parameter passing out of aliasing considerations If an actual parameter that is a type conversion is passed by reference but not addressable, the temporary that is created and whose address is passed instead may need to be in the target type of the conversion to fulfill the requirements of strict aliasing. gcc/ada/ChangeLog: * gcc-interface/trans.cc (Call_to_gnu): If the formal is passed by reference and the actual is a type conversion but not addressable, create the temporary in the target type of the conversion if this is needed to enforce strict aliasing. Diff: --- gcc/ada/gcc-interface/trans.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/gcc/ada/gcc-interface/trans.cc b/gcc/ada/gcc-interface/trans.cc index 93f67404ddb4..5f8a18eebb72 100644 --- a/gcc/ada/gcc-interface/trans.cc +++ b/gcc/ada/gcc-interface/trans.cc @@ -5010,9 +5010,12 @@ Call_to_gnu (Node_Id gnat_node, tree *gnu_result_type_p, tree gnu_target, TREE_TYPE (gnu_name)))) gnu_name = convert (gnu_name_type, gnu_name); - /* If the temporary is created because of aliasing considerations, + /* If the temporary is created because of aliasing considerations, + or would have been so created if the actual was addressable, it must be in the target type of the (unchecked) conversion. */ - if (aliasing) + if (aliasing + || (node_is_type_conversion (gnat_actual) + && !aliasable_p (gnu_name, gnu_actual_type))) { if (Nkind (gnat_actual) == N_Unchecked_Type_Conversion) gnu_name = unchecked_convert (gnu_actual_type, gnu_name,