https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112407

Paul Thomas <pault at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2023-11-07
     Ever confirmed|0                           |1

--- Comment #2 from Paul Thomas <pault at gcc dot gnu.org> ---
(In reply to Tomáš Trnka from comment #1)
> Created attachment 56516 [details]
> Hacky patch working around the issue on this testcase

Hi Tomáš,

'newcopyother' is determined to be recursive. The ICE arises because the line
buffer field, lb, of the expression locus is NULL (where = {nextc = 0x0, lb =
0x0}).

Compiling with -frecursive fixes the ICE in the testcase. Does that permit the
build to proceed?

This fixes the problem and is regression testing as I write.

diff --git a/gcc/fortran/resolve.cc b/gcc/fortran/resolve.cc
index 81a14653a04..192a9c74b41 100644
--- a/gcc/fortran/resolve.cc
+++ b/gcc/fortran/resolve.cc
@@ -1969,6 +1969,10 @@ resolve_procedure_expression (gfc_expr* expr)
       || (sym->attr.function && sym->result == sym))
     return true;

+  /* Do not test "hidden" module symbols for recursion.  */
+  if (sym->attr.use_assoc && expr->symtree->name[0] == '@')
+    return true;
+
   /* A non-RECURSIVE procedure that is used as procedure expression within its
      own body is in danger of being called recursively.  */
   if (is_illegal_recursion (sym, gfc_current_ns))

Reply via email to