public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "sgk at troutmask dot apl.washington.edu" <gcc-bugzilla@gcc.gnu.org> 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 [thread overview] Message-ID: <bug-99506-4-ji3gbuEUL1@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-99506-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99506 --- Comment #8 from Steve Kargl <sgk at troutmask dot apl.washington.edu> --- 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=99506 > > --- Comment #7 from Steve Kargl <sgk at troutmask dot apl.washington.edu> --- > 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=99506 > > > > --- 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 context: > > > > > > real(double), parameter:: latt(jmax) = [(latt100(i)/100.d0, j=1,jmax)] > > > > > > but the middle-end sees a readonly global (TREE_STATIC) variable. > > > > There is a possibly related issue in pr91960. > > > > 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 > checking. > 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 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 + initialize an array constant. For example, + INTEGER I,J + INTEGER, PARAMETER :: A(3) = [(I, I = 1, 3)] ! OK + INTEGER, PARAMETER :: B(3) = [(A(J), I = 1, 3)] ! Not OK + This check catches the typo. */ + if (sym->attr.dimension + && sym->value && sym->value->expr_type == EXPR_ARRAY + && !gfc_is_constant_expr (sym->value)) + { + gfc_error ("Expecting constant expression near %L", &sym->value->where); + return false; + } + return true; }
prev parent reply other threads:[~2021-03-11 1:38 UTC|newest] Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-03-10 6:32 [Bug fortran/99506] New: " furue at hawaii dot edu 2021-03-10 7:53 ` [Bug fortran/99506] " marxin at gcc dot gnu.org 2021-03-10 8:00 ` kargl at gcc dot gnu.org 2021-03-10 8:18 ` furue at hawaii dot edu 2021-03-10 8:39 ` rguenth at gcc dot gnu.org 2021-03-10 16:52 ` sgk at troutmask dot apl.washington.edu 2021-03-10 22:22 ` anlauf at gcc dot gnu.org 2021-03-10 22:59 ` sgk at troutmask dot apl.washington.edu 2021-03-11 1:38 ` sgk at troutmask dot apl.washington.edu [this message]
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-99506-4-ji3gbuEUL1@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).