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

--- Comment #15 from Paul Thomas <pault at gcc dot gnu.org> ---
(In reply to markeggleston from comment #12)
> Created attachment 48155 [details]
> Proposed fix
> 
> Sorry for the duplicate (PR94430) I missed this PR.
> 
> The cause of the errors messages is due to most of the code in expr.c
> introduced by PR93600 being deleted.
> 
> I restored the code, the error went away, however, bessel_5_redux.f90
> resulted in an ICE.
> 
> When this bit of PR94246 is put back:
> 
> @@ -2314,9 +2296,8 @@ scalarize_intrinsic_call (gfc_expr *e, bool init_flag)
>    gfc_constructor_base ctor;
>    gfc_constructor *args[5] = {};  /* Avoid uninitialized warnings.  */
>    gfc_constructor *ci, *new_ctor;
> -  gfc_expr *expr, *old;
> +  gfc_expr *expr, *old, *p;
>    int n, i, rank[5], array_arg;
> -  int errors = 0;
>  
>    if (e == NULL)
>      return false;
> @@ -2384,8 +2365,6 @@ scalarize_intrinsic_call (gfc_expr *e, bool init_flag)
>        n++;
>      }
>  
> -  gfc_get_errors (NULL, &errors);
> -
>    /* Using the array argument as the master, step through the array
>       calling the function for each element and advancing the array
>       constructors together.  */
> @@ -2419,8 +2398,12 @@ scalarize_intrinsic_call (gfc_expr *e, bool init_flag)
>        /* Simplify the function calls.  If the simplification fails, the
>        error will be flagged up down-stream or the library will deal
>        with it.  */
> -      if (errors == 0)
> -     gfc_simplify_expr (new_ctor->expr, 0);
> +      p = gfc_copy_expr (new_ctor->expr);
> +
> +      if (!gfc_simplify_expr (p, init_flag))
> +     gfc_free_expr (p);
> +      else
> +     gfc_replace_expr (new_ctor->expr, p);
>  
>        for (i = 0; i < n; i++)
>       if (args[i])
> 
> bessel_5_redux.f90.
> 
> I think
> 
>       if (errors == 0)
>         gfc_simplify_expr (new_ctor->expr, 0);
> 
> caused the ICE.
> 


Hi Mark,

Yes, indeed that was the problem. The simplification of the scalar expression
was coming back with a false but no error, which then fed a broken array
expression to the next stage of simplification and this caused the segfault.

I have a real problem to understand how I was able to do this without git
throwing a wobbler. Previously I have been firmly and vociferously prevented
from doing such things but on this occasion was allowed to screw things up.

I am a total tyro with git and don't have over much time outside of my
professional commitments to study the documentation. I would be grateful, if
either you or one of the others in copy to this PR could point me to a set of
clearly described workflows. Compared to svn, git seems to me to be
unpleasantly ass-backwards.

Many thanks for fixing the mess that I made. Bizarrely, the COVID-19 crisis has
me busier than ever even though working from home. I was aware that there was
time pressure but just could not respond to it.

Thanks again

Paul

Reply via email to