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

            Bug ID: 85855
           Summary: [7 Regression] (Maybe) uninitialized descriptor fields
                    of an allocatable array component of a function result
           Product: gcc
           Version: 7.3.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: vladimir.fuka at gmail dot com
  Target Milestone: ---

This code does not issue any warning in GCC 4.8 to 6 but does for GCC 7.3.1:

module test

  implicit none

  type grid
    integer, allocatable :: mask(:,:,:)
  end type

contains

  function reduce(g) result(res)
    type(grid) :: res
    class(grid), intent(in) :: g
    res%mask = g%mask
  end function

end module


> gfortran-7 -c uninit2.f90 -fbacktrace -g -Wall
uninit2.f90:14:0:

     res%mask = g%mask

Warning: ‘res.mask.offset’ is used uninitialized in this function
[-Wuninitialized]
uninit2.f90:14:0: Warning: ‘res.mask.dim[0].lbound’ is used uninitialized in
this function [-Wuninitialized]
uninit2.f90:14:0: Warning: ‘res.mask.dim[0].ubound’ is used uninitialized in
this function [-Wuninitialized]
uninit2.f90:14:0: Warning: ‘res.mask.dim[1].lbound’ is used uninitialized in
this function [-Wuninitialized]
uninit2.f90:14:0: Warning: ‘res.mask.dim[1].ubound’ is used uninitialized in
this function [-Wuninitialized]
uninit2.f90:14:0: Warning: ‘res.mask.dim[2].lbound’ is used uninitialized in
this function [-Wuninitialized]
uninit2.f90:14:0: Warning: ‘res.mask.dim[2].ubound’ is used uninitialized in
this function [-Wuninitialized]
uninit2.f90:14:0:

     res%mask = g%mask

Warning: ‘res.mask.dim[0].lbound’ may be used uninitialized in this function
[-Wmaybe-uninitialized]
uninit2.f90:14:0: Warning: ‘res.mask.dim[0].ubound’ may be used uninitialized
in this function [-Wmaybe-uninitialized]
uninit2.f90:14:0: Warning: ‘res.mask.dim[1].lbound’ may be used uninitialized
in this function [-Wmaybe-uninitialized]
uninit2.f90:14:0: Warning: ‘res.mask.dim[1].ubound’ may be used uninitialized
in this function [-Wmaybe-uninitialized]
uninit2.f90:14:0: Warning: ‘res.mask.dim[2].lbound’ may be used uninitialized
in this function [-Wmaybe-uninitialized]
uninit2.f90:14:0: Warning: ‘res.mask.dim[2].ubound’ may be used uninitialized
in this function [-Wmaybe-uninitialized]
uninit2.f90:14:0: Warning: ‘res.mask.dim[0].ubound’ may be used uninitialized
in this function [-Wmaybe-uninitialized]
uninit2.f90:14:0: Warning: ‘res.mask.dim[0].lbound’ may be used uninitialized
in this function [-Wmaybe-uninitialized]
uninit2.f90:14:0: Warning: ‘res.mask.dim[1].ubound’ may be used uninitialized
in this function [-Wmaybe-uninitialized]
uninit2.f90:14:0: Warning: ‘res.mask.dim[1].lbound’ may be used uninitialized
in this function [-Wmaybe-uninitialized]
uninit2.f90:14:0: Warning: ‘res.mask.dim[2].ubound’ may be used uninitialized
in this function [-Wmaybe-uninitialized]
uninit2.f90:14:0: Warning: ‘res.mask.dim[2].lbound’ may be used uninitialized
in this function [-Wmaybe-uninitialized]

Reply via email to