https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102966
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). > > The four-line test program is: > > PROGRAM test > integer, allocatable :: ar(:) > print *, size(ar) > END PROGRAM test > > I compile with flags -Wall and -fcheck=all > > gfortran -Wall -fcheck=all test.f90 > > This produces a.out without warning, and then ./a.out just prints 0 without > error message. > > The expected result for me, especially with -fcheck=all, is an error exit 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.