https://gcc.gnu.org/g:0c598db8978a3569bd250a67ac52b7a88d544041
commit 0c598db8978a3569bd250a67ac52b7a88d544041 Author: Alexandre Oliva <ol...@adacore.com> Date: Fri Jun 28 05:35:58 2024 -0300 make_type_from_size: avoid TYPE_DEBUG_TYPE / TREE_TYPE loops Before make_type_from_size links a preexisting type to the newly-created narrower type to use the latter for debug information purposes, make sure that won't form a loop: if the type didn't have TREE_TYPE set, the new type will link back to the original type, rather than to the type's base type, and then modified_type_die would recurse indefinitely between them. for gcc/ada/ChangeLog * gcc-interface/utils.cc (make_type_from_size): Avoid forming loops. Diff: --- gcc/ada/gcc-interface/utils.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/gcc/ada/gcc-interface/utils.cc b/gcc/ada/gcc-interface/utils.cc index daf8d7ccdc5..b46e035e1d4 100644 --- a/gcc/ada/gcc-interface/utils.cc +++ b/gcc/ada/gcc-interface/utils.cc @@ -1427,10 +1427,12 @@ make_type_from_size (tree type, tree size_tree, bool for_biased) /* Enable us to avoid creating the same narrower type multiple times, and avoid duplication in debug information, by mapping the wider type to the narrower version. If biasing is - different, we use the narrower type for debug information. */ + different, we use the narrower type for debug information. + Be careful to avoid forming loops. */ if (TYPE_CAN_HAVE_DEBUG_TYPE_P (type) && !TYPE_DEBUG_TYPE (type) - && biased_p == for_biased) + && biased_p == for_biased + && TREE_TYPE (new_type) != type) SET_TYPE_DEBUG_TYPE (type, new_type); return new_type;