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

            Bug ID: 88455
           Summary: False positive for allocatable character array of
                    deferred length, ALLOCATE using SOURCE/MOLD
                    [-Wuninitialized]
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: adam at aphirst dot karoo.co.uk
  Target Milestone: ---

program test
  implicit none

  call F(1, 10, 30)

contains

  subroutine F(i,j,k)
    integer,      intent(in)  :: i, j, k
    character(:), allocatable :: line(:)
    ! with a hard-coded len, the warning goes away
    ! similarly if it's deferred-length but scalar
    !character(k), allocatable :: line(:) 

    allocate( line(i:j), source = repeat(" ",k) )
    print *, size(line) ! gives 10
    print *, len(line)  ! gives 30

  end subroutine
end program test

---

Warning: ‘.line’ is used uninitialized in this function [-Wuninitialized]

---

Using a single ALLOCATE statement for an allocatable array of CHARACTER with
deferred length (using either SOURCE or MOLD) results in a false positive for
uninitialised variables.

The issue doesn't occur if the variable is ONLY an allocatable array, or
respectively if it's ONLY of deferred length. The issue occurs only when both
degrees of freedom are present.

System:
-------
gcc (GCC) 8.2.1 20181127
Arch Linux x86_64

Reply via email to