From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 533EC3858008; Tue, 8 Mar 2022 18:44:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 533EC3858008 From: "tkoenig at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/104811] maxloc/minloc cannot accept character arguments without `dim` optional argument. Date: Tue, 08 Mar 2022 18:44:58 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Version: 11.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: tkoenig at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P4 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 Mar 2022 18:44:58 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D104811 Thomas Koenig changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |tkoenig at gcc dot gnu.org --- Comment #4 from Thomas Koenig --- (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. >=20 > Good observation. >=20 > 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: >=20 > /* Special case for character maxloc. Remove unneeded actual > arguments, then call a library function. */ >=20 > The obvious solution is to punt on character array arguments: >=20 > 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 !=3D 1 > || fn->value.function.actual =3D=3D NULL > || fn->value.function.actual->expr =3D=3D NULL > + || fn->value.function.actual->expr->ts.type =3D=3D BT_CHARACTER > || fn->value.function.actual->expr->rank !=3D 1) > return; Thanks for analyzing this before I ever got a round tuit. Patch is pre-approved or obvious, take your pick :-)=