From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 7D19E3858004; Thu, 11 Mar 2021 01:38:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7D19E3858004 From: "sgk at troutmask dot apl.washington.edu" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/99506] internal compiler error: in record_reference, at cgraphbuild.c:64 Date: Thu, 11 Mar 2021 01:38:49 +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: X-Bugzilla-Severity: normal X-Bugzilla-Who: sgk at troutmask dot apl.washington.edu 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: 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: Thu, 11 Mar 2021 01:38:49 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D99506 --- Comment #8 from Steve Kargl -= -- On Wed, Mar 10, 2021 at 10:59:39PM +0000, sgk at troutmask dot apl.washington.edu wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D99506 >=20 > --- Comment #7 from Steve Kargl = --- > On Wed, Mar 10, 2021 at 10:22:45PM +0000, anlauf at gcc dot gnu.org wrote: > > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D99506 > >=20 > > --- Comment #6 from anlauf at gcc dot gnu.org --- > > (In reply to Richard Biener from comment #4) > > > I don't know fortran enough for what 'parameter' means in this contex= t: > > >=20 > > > real(double), parameter:: latt(jmax) =3D [(latt100(i)/100.d0, j= =3D1,jmax)] > > >=20 > > > but the middle-end sees a readonly global (TREE_STATIC) variable. > >=20 > > There is a possibly related issue in pr91960. > >=20 >=20 > Yes, same problem. An uninitialized *variable* is used in > an implied-do loop, which is an ac-value expression. Perhaps, > resolve.c(resolve_fl_parameter) needs to do some deeper=20 > checking. >=20 This patch fixes both 99506 and 91960. I cannot commit. Whoever decides to commit the patch needs to convert the code in 91960 into a testcase. Otherwise, this patch=20 will fester in bugzilla with other 20 or so patches I've included in audit trails of those PRs. diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index 2a91ae743ea..84e93dbc1fd 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -15179,6 +15186,20 @@ resolve_fl_parameter (gfc_symbol *sym) return false; } + /* Some programmers can have a typo when using an implied-do loop to=20 + initialize an array constant. For example,=20 + INTEGER I,J + INTEGER, PARAMETER :: A(3) =3D [(I, I =3D 1, 3)] ! OK + INTEGER, PARAMETER :: B(3) =3D [(A(J), I =3D 1, 3)] ! Not OK + This check catches the typo. */ + if (sym->attr.dimension + && sym->value && sym->value->expr_type =3D=3D EXPR_ARRAY + && !gfc_is_constant_expr (sym->value)) + { + gfc_error ("Expecting constant expression near %L", &sym->value->whe= re); + return false; + } + return true; }=