From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 81CF83858C52; Sat, 18 May 2024 16:36:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 81CF83858C52 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1716050174; bh=zMz7WutqMGeCZWLqGD/ZLTwxnGmzyjpg3DyIGFQszzA=; h=From:To:Subject:Date:In-Reply-To:References:From; b=mh2ekKt0PFfEZzD1Z/KsHFwRsjmxwyK9wH6AHkwXef9HYSQVi4uPL+GnXhZEe3fLR fK2MU/UdYJ0fycgiBxwV4a2mGp8rg9kUKeQV3cTXKt7nw1Lg5bp7dhmXe1IMn1cXye ASlI0/Sa2rgF+96rzkFVOMD10x1RMQ2NlZaxJm+Y= From: "burnus at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/115150] [12/13/14/15 Regression] SHAPE of zero-sized array yields a negative value Date: Sat, 18 May 2024 16:36:14 +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: 15.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: burnus at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 12.5 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: target_milestone 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D115150 Tobias Burnus changed: What |Removed |Added ---------------------------------------------------------------------------- Target Milestone|--- |12.5 CC| |sandra at gcc dot gnu.org --- Comment #1 from Tobias Burnus --- Looking at the dump, GCC 11 has: _gfortran_shape_4 (&parm.3, D.3966); while GCC 12 has: x[S.3] =3D (integer(kind=3D4)) (((unsigned int) a.dim[S.3].ubound - (= unsigned int) a.dim[S.3].lbound) + 1); * * * * Probably caused by: r12-4591-g1af78e731feb93 Author: Sandra Loosemore Date: Tue Oct 19 21:11:15 2021 -0700 Fortran: Fixes and additional tests for shape/ubound/size [PR94070] This patch reimplements the SHAPE intrinsic to be inlined similarly to LBOUND and UBOUND, instead of as a library call, to avoid an unnecessary array copy. Various bugs are also fixed. gcc/fortran/ PR fortran/94070 * * * SHAPE has: "Result Value. The result has a value whose i-th element is equal to the ex= tent of dimension i of SOURCE, except that if SOURCE is assumed-rank, and associ= ated with an assumed-size array, the last element is equal to =E2=88=921." Thus, an example for the latter: GCC 11.4 - good: 0 2 -1 GCC 12 (to trunk) - wrong: -3 2 -1 integer :: x(10) call f(x, -3) contains subroutine f(y,n) integer :: y(1:n,2,*) call g(y) end subroutine g(z) integer :: z(..) print *, shape(z) end end=