https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85565

            Bug ID: 85565
           Summary: LEN() intrinsic returns zero when given zero-sized
                    array
           Product: gcc
           Version: 6.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: urbanjost at comcast dot net
  Target Milestone: ---

The following code returns "10,0" instead of "10,20"

     program test_len
     character(len=:), allocatable :: arr(:)
     arr=[ character(len=10)::'A','B']
     write(*,*)len(arr)                   ! gets "10", which is what I expect
     arr=[ character(len=20)::]
     write(*,*)len(arr)             ! gets "0", but I think it should get "20"
     end program test_len

That is, when passed a zero-length array the LEN(3f) intrinsic appears to
always report a value of zero(0). Even if the array is of zero size it still
has a length defined for the elments, and I believe it should return that,
not zero.

Reply via email to