public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "sandra at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/94070] Assumed-rank arrays – bounds mishandled, SIZE/SHAPE/UBOUND/LBOUND Date: Sun, 22 Aug 2021 19:53:10 +0000 [thread overview] Message-ID: <bug-94070-4-sskruKteDy@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-94070-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94070 sandra at gcc dot gnu.org changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|unassigned at gcc dot gnu.org |sandra at gcc dot gnu.org --- Comment #8 from sandra at gcc dot gnu.org --- In gfc_desc_to_cfi_desc (in libgfortran/runtime/ISO_Fortran_binding.c): /* Assumed size arrays have gfc ubound == 0 and CFI extent = -1. */ if (n == GFC_DESCRIPTOR_RANK (s) - 1 && GFC_DESCRIPTOR_LBOUND(s, n) == 1 && GFC_DESCRIPTOR_UBOUND(s, n) == 0) d->dim[n].extent = -1; else d->dim[n].extent = (CFI_index_t)GFC_DESCRIPTOR_UBOUND(s, n) - (CFI_index_t)GFC_DESCRIPTOR_LBOUND(s, n) + 1; The comment and test are only correct if the lower bound of the array dimension either defaults to 1 or is explicitly specified as 1. It does appear that the ubound == 0 part is true, but this means e.g. an array dimension specified as -3:* is indistinguishable from -3:0. I think this needs to be corrected at the point where the GFC descriptor is created; perhaps set ubound = lbound - 1? Or also set lbound = 1 as the code snippet above checks? Assumed-size arrays can't be pointers or allocatable so their bounds don't need to be preserved across calls, but maybe GFC descriptors are used for other purposes where it matters?
next prev parent reply other threads:[~2021-08-22 19:53 UTC|newest] Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top [not found] <bug-94070-4@http.gcc.gnu.org/bugzilla/> 2020-07-21 15:22 ` dominiq at lps dot ens.fr 2021-03-01 8:34 ` burnus at gcc dot gnu.org 2021-07-01 22:55 ` sandra at gcc dot gnu.org 2021-08-22 19:53 ` sandra at gcc dot gnu.org [this message] 2021-09-06 11:56 ` burnus at gcc dot gnu.org 2021-09-27 12:06 ` cvs-commit at gcc dot gnu.org 2021-10-12 2:57 ` sandra at gcc dot gnu.org 2021-10-21 2:28 ` cvs-commit at gcc dot gnu.org 2021-10-21 18:03 ` sandra at gcc dot gnu.org 2022-01-09 23:25 ` pinskia at gcc dot gnu.org
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-94070-4-sskruKteDy@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).