From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id A41753858404; Sun, 22 Aug 2021 19:53:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A41753858404 From: "sandra at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: =?UTF-8?B?W0J1ZyBmb3J0cmFuLzk0MDcwXSBBc3N1bWVkLXJhbmsgYXJyYXlz?= =?UTF-8?B?IOKAkyBib3VuZHMgbWlzaGFuZGxlZCwgU0laRS9TSEFQRS9VQk9VTkQvTEJP?= =?UTF-8?B?VU5E?= Date: Sun, 22 Aug 2021 19:53:10 +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: 10.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: sandra at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P4 X-Bugzilla-Assigned-To: sandra at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: assigned_to 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: Sun, 22 Aug 2021 19:53:10 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D94070 sandra at gcc dot gnu.org changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|unassigned at gcc dot gnu.org |sandra at gcc dot g= nu.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 =3D=3D 0 and CFI extent =3D = -1. */ if (n =3D=3D GFC_DESCRIPTOR_RANK (s) - 1 && GFC_DESCRIPTOR_LBOUND(s, n) =3D=3D 1 && GFC_DESCRIPTOR_UBOUND(s, n) =3D=3D 0) d->dim[n].extent =3D -1; else d->dim[n].extent =3D (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 dimen= sion either defaults to 1 or is explicitly specified as 1. It does appear that = the ubound =3D=3D 0 part is true, but this means e.g. an array dimension specif= ied 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 =3D lbound - 1? Or also set lbound =3D 1 as th= e 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 descrip= tors are used for other purposes where it matters?=