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

Mikael Morin <mikael at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mikael at gcc dot gnu.org

--- Comment #9 from Mikael Morin <mikael at gcc dot gnu.org> ---
(In reply to Steve Kargl from comment #7)
> (In reply to Steve Kargl from comment #6)
> > (In reply to Harald Anlauf from comment #5)
> > > 
> > > This function is very old code, so we need to exercise it a bit.
> > > Can you do that?
> > 
> > I'll see what I can do.  It's been a long time since I hacked on
> > gfortran source code.
> 
> This simple patch fixes OP's issue.  I haven't run check-fortran,
> as I need to update my gcc tree and rebuild everything first.
> 
> 
> diff --git a/gcc/fortran/trans-expr.cc b/gcc/fortran/trans-expr.cc
> index 289ae0311fa..28db117f1ae 100644
> --- a/gcc/fortran/trans-expr.cc
> +++ b/gcc/fortran/trans-expr.cc
> @@ -2288,16 +2288,14 @@ tree
>  gfc_get_expr_charlen (gfc_expr *e)
>  {
>    gfc_ref *r;
> -  tree length;
> +  tree length = NULL_TREE;
>    tree previous = NULL_TREE;
>    gfc_se se;
>  
> -  gcc_assert (e->expr_type == EXPR_VARIABLE
> -             && e->ts.type == BT_CHARACTER);
> +  gcc_assert (e->ts.type == BT_CHARACTER);
>  
> -  length = NULL; /* To silence compiler warning.  */
> -
> -  if (is_subref_array (e) && e->ts.u.cl->length)
> +  if ((is_subref_array (e) || e->expr_type == EXPR_FUNCTION) 
> +      && e->ts.u.cl->length)
>      {
>        gfc_se tmpse;
>        gfc_init_se (&tmpse, NULL);

That's another way. It could work I guess.

Reply via email to