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

Tobias Burnus <burnus at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |burnus at gcc dot gnu.org

--- Comment #3 from Tobias Burnus <burnus at gcc dot gnu.org> ---
The issue only seems to occur for functions which do not return an array
descriptor. For the latter it works.

Needs to be handled in trans-array.c's gfc_array_allocate and/or
gfc_array_init_size.

program p
 implicit none
 integer, allocatable :: a(:), b(:), c(:)
 allocate( a, source=f(3) )
 allocate( b, source=g(3))
 allocate( c, source=h(3))
 write(*,*) lbound(a,1), ubound(a,1) ! prints 0 2 instead of 1 3
 write(*,*) lbound(b,1), ubound(b,1) ! prints 1 3 as expected
 write(*,*) lbound(c,1), ubound(c,1) ! prints 3 5 as expected

contains
 pure function g(i) result(r)
  integer, value, intent(in) :: i
  integer, allocatable :: r(:)
  r = [1,2,3]
 end function g

 pure function h(i) result(r)
  integer, value, intent(in) :: i
  integer, allocatable :: r(:)
  allocate(r(3:5))
  r = [1,2,3]
 end function h

 pure function f(i)
  integer, intent(in) :: i
  integer :: f(i)
   f = 2*i
 end function f
end program p

Reply via email to