https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104811
Thomas Koenig <tkoenig at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |tkoenig at gcc dot gnu.org --- Comment #4 from Thomas Koenig <tkoenig at gcc dot gnu.org> --- (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 :-)