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

--- Comment #5 from Amir Shahmoradi <a.shahmoradi at gmail dot com> ---
(In reply to Thomas Koenig from comment #4)
> (In reply to anlauf from comment #2)
> > (In reply to kargl from comment #1)
> > > Compiles and executes without optimization or if -fno-frontend-optimize is
> > > used with optimization.
> > 
> > Good observation.
> > 
> > The inline expansion that may be helpful for integer and real arguments
> > will not even be done in trans-intrinsic.cc, as the following comment
> > explains:
> > 
> >   /* Special case for character maxloc.  Remove unneeded actual
> >      arguments, then call a library function.  */
> > 
> > The obvious solution is to punt on character array arguments:
> > 
> > diff --git a/gcc/fortran/frontend-passes.cc b/gcc/fortran/frontend-passes.cc
> > index 4033f27df99..5eba6345145 100644
> > --- a/gcc/fortran/frontend-passes.cc
> > +++ b/gcc/fortran/frontend-passes.cc
> > @@ -2276,6 +2276,7 @@ optimize_minmaxloc (gfc_expr **e)
> >    if (fn->rank != 1
> >        || fn->value.function.actual == NULL
> >        || fn->value.function.actual->expr == NULL
> > +      || fn->value.function.actual->expr->ts.type == BT_CHARACTER
> >        || fn->value.function.actual->expr->rank != 1)
> >      return;
> 
> Thanks for analyzing this before I ever got a round tuit.
> 
> Patch is pre-approved or obvious, take your pick :-)

Thank you for your prompt action and fix. Glad to hear both "pre-approved" and
"obvious".

Reply via email to