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

--- Comment #6 from anlauf at gcc dot gnu.org ---
Created attachment 58302
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=58302&action=edit
Partial patch

This change prevents the ICE and leads to a correct shape of the function
result for the following testcase:

program p
  implicit none
  real :: w(2,3)
  real, allocatable :: y(:)
  y = h(w)
  print *, size (y) ! Should print 6
  print *, y
  deallocate (y)
contains
  function h(x) result (g)
    real :: x(..)
    real :: g(product(shape(x)))
    integer :: i
    print *, shape (x)
    print *, size (g)
    g = [(real(i),i=1,size(g))]
    print *, g
  end
end

After the patch this prints:

           2           3
           6
   1.00000000       2.00000000       3.00000000       4.00000000      
5.00000000       6.00000000    
           1
   1.00000000    

So the function result is not allocated correctly.

Reply via email to