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

--- Comment #7 from Steve Kargl <sgk at troutmask dot apl.washington.edu> ---
On Thu, Oct 19, 2023 at 08:00:27AM +0000, aluaces at udc dot es wrote:
> 
> It says something about a non-recursive function likely calling itself.  I 
> will
> inspect my source, even it is a bit too big.  Maybe a better solution would be
> if I compiled gcc with debugging flags.  Can I just use C_FLAGS="-O0 -g" and
> CXX_FLAGS="-O0 -g" at configure time, or if is there a specific configure 
> flag?

I doubt that these options will help with this problem.  Those
are for building your application with debugging info.  The issue
is the compiler itself is dying.

> 1078            gcc_assert (loc->nextc - loc->lb->line >= 0);
> (gdb) bt
> #0  gfc_format_decoder (pp=0x2706750, text=0x7fffffffb840, spec=0x2708d10 "L",
> precision=<optimized out>, wide=false, set_locus=false, hash=false,
> quoted=0x7fffffffb667, buffer_ptr=0x2708b00)
>     at ../../gcc-13.2.0/gcc/fortran/error.cc:1078
> #1  0x0000000001b44c0a in pp_format (pp=<optimized out>,
> text=text@entry=0x7fffffffb840) at ../../gcc-13.2.0/gcc/pretty-print.cc:1475
> #2  0x0000000001b34e02 in diagnostic_report_diagnostic (context=0x26ee380
> <global_diagnostic_context>, diagnostic=diagnostic@entry=0x7fffffffb840) at
> ../../gcc-13.2.0/gcc/diagnostic.cc:1592
> #3  0x000000000071cbc8 in gfc_report_diagnostic (diagnostic=0x7fffffffb840) at
> ../../gcc-13.2.0/gcc/fortran/error.cc:890
> #4  gfc_warning(int, const char *, typedef __va_list_tag __va_list_tag *)
> (opt=0,
>     gmsgid=0x1c9c420 "Non-RECURSIVE procedure %qs at %L is possibly calling
> itself recursively.  Declare it RECURSIVE or use %<-frecursive%>",
> ap=ap@entry=0x7fffffffb9c8)
>     at ../../gcc-13.2.0/gcc/fortran/error.cc:923
> #5  0x000000000071d287 in gfc_warning (opt=opt@entry=0,
> gmsgid=gmsgid@entry=0x1c9c420 "Non-RECURSIVE procedure %qs at %L is possibly
> calling itself recursively.  Declare it RECURSIVE or use %<-frecursive%>")
>     at ../../gcc-13.2.0/gcc/fortran/error.cc:954

I suspect that the locus associate with %L in the above
error message is undefined (i.e., a NULL pointer).  This
likely means expr in the next frame is missing some info.

> #6  0x00000000007a275f in resolve_procedure_expression (expr=0x32a9530) at
> ../../gcc-13.2.0/gcc/fortran/resolve.cc:1956

Can you do 

(gdb) up 6
(gdb) p *expr

You'll likely see expr->where is either NULL or its components are.
My sources are bit newer, resolve.cc:1974 is

  if (is_illegal_recursion (sym, gfc_current_ns))
    gfc_warning (0, "Non-RECURSIVE procedure %qs at %L is possibly calling"
                 " itself recursively.  Declare it RECURSIVE or use"
                 " %<-frecursive%>", sym->name, &expr->where);

You can try replacing &expr->where with gfc_current_locus.  I don't
remember if the & is needed with gfc_current_locus.

Reply via email to