[Bug fortran/104811] maxloc/minloc cannot accept character arguments without `dim` optional argument.
anlauf at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Mon Mar 7 21:47:56 GMT 2022
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104811
anlauf at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever confirmed|0 |1
CC| |anlauf at gcc dot gnu.org
Last reconfirmed| |2022-03-07
--- Comment #2 from anlauf at gcc dot gnu.org ---
(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;
More information about the Gcc-bugs
mailing list