From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 70D0F3858C27; Wed, 27 Oct 2021 19:01:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 70D0F3858C27 From: "kargl at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/102966] size() returns 0 for an unallocated array, no error message or error exit Date: Wed, 27 Oct 2021 19:01:19 +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: unknown X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: kargl 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: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: 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 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: Wed, 27 Oct 2021 19:01:19 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D102966 kargl at gcc dot gnu.org changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |kargl at gcc dot gnu.org --- Comment #1 from kargl at gcc dot gnu.org --- (In reply to Bastiaan Braams from comment #0) > Using GNU Fortran (GCC) 10.3.1 20210422 (Red Hat 10.3.1-1). >=20 > The four-line test program is: >=20 > PROGRAM test > integer, allocatable :: ar(:) > print *, size(ar) > END PROGRAM test >=20 > I compile with flags -Wall and -fcheck=3Dall >=20 > gfortran -Wall -fcheck=3Dall test.f90 >=20 > This produces a.out without warning, and then ./a.out just prints 0 witho= ut > error message. >=20 > The expected result for me, especially with -fcheck=3Dall, is an error ex= it at > run time. Un unallocated array is not a zero-size array. The code is invalid Fortran. A compiler can do anything, and that includes what you think it should do. To be specific, from F2018 standard 9.7.1.3 Allocation of allocatable variables The allocation status of an allocatable entity is one of the following at any time. * The status of an allocatable variable becomes "allocated" if ... * An allocatable variable has a status of "unallocated" if it is not allocated. The status of an allocatable variable becomes unallocated if it is deallocated (9.7.3) or if it is given that status by the intrinsic subroutine MOVE_ALLOC. An allocatable variable with this status shall not be referenced or defined. It shall not be supplied as an actual argument corresponding to a nonallocatable nonoptional dummy argument, except to certain intrinsic inquiry functions. It may be allocated with the ALLOCATE statement. Deallocating it causes an error condition in the DEALLOCATE statement. The result of the intrinsic function ALLOCATED (16.9.11) is false for such a variable. Those "shall"s that you see apply to the programmer not the processor. This should be closed with either INVALID, but I'll let someone else perform the honors.=