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

Paul Thomas <pault at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |pault at gcc dot gnu.org

--- Comment #6 from Paul Thomas <pault at gcc dot gnu.org> ---
Created attachment 58348
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=58348&action=edit
Fix for this PR

This works and even regtests. I will include character lengths before
submitting.

The eventual testcase is rather more elaborate but the version below gives an
idea of what is now fixed,

Paul

module m1
   implicit none
   integer, parameter :: dp = kind([double precision::])
   contains
      function f(x)
         integer, intent(in) :: x
         real(dp) f(x/2)
         real(dp) g(x/2)
!         block
         integer y(size(f)+1)
         integer z(size(f) + size(y)) ! This caused all manner of trouble.
         f = 10.0
         y = 1
         z = 1
         write(*,*) 'size(f) = ', size(f), f
         write(*,*) 'size(y) = ', size(y), y
         write(*,*) 'size(z) = ', size(z), z
!         end block
      end function f
      function e(x) result(f)
         integer, intent(in) :: x
         real(dp) f(x/2)
         real(dp) g(x/2)
         integer y(size(f)+1)
         integer z(size(f) + size(y)) ! As did this.
         f = 10.0
         y = 1
         z = 1
         write(*,*) 'size(f) = ', size(f), f
         write(*,*) 'size(y) = ', size(y), y
         write(*,*) 'size(z) = ', size(z), z
      end function e
end module m1

program bug3
   use m1
   implicit none
   real(dp) y

   y = sum(f(2))
   print *, y
   y = sum(e(4))
   print *, y
end program bug3

Reply via email to