Bug ID: 86117
           Summary: bogus warning maybe-uninitialized with class(*) and
                    source argument in allocate
           Product: gcc
           Version: 8.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot
          Reporter: mscfd at gmx dot net
  Target Milestone: ---

Compiling the following module with

gfortran -Og -Wall -fcheck=all -c mod.f90


 Warning: ‘<anonymous>’ may be used uninitialized in this function

When leaving out any one of the three options -Og, -Wall or -fcheck=all the
warning disappears.

When replacing class(*) with integer the warning also disappears.

When using scalars for a and b (omitting the dimension(:) part and the do loop)
the warning also disappears.

module mod

public sub

   type, public :: generic
      class(*), allocatable :: item
      ! with integer instead of class(*), there is no warning
!      integer, allocatable :: item
   end type generic


   subroutine sub(a, b)
      type(generic), dimension(:), intent(in) :: a
      type(generic), dimension(:), intent(out) :: b

      integer :: i

      do i = 1, 10
         allocate(b(i)%item, source=a(i)%item)
      end do
   end subroutine sub

end module mod

Reply via email to