http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58229
janus at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|[F03] Memory leak with |[F03] Memory leak with
|allocatable function result |allocatable scalar function
| |result
--- Comment #3 from janus at gcc dot gnu.org ---
As the following test case demonstrates, the leak actually only happens for
allocatable *scalar* results. Array results already get a temporary, which is
passed as argument and deallocated after the call.
implicit none
integer :: i, arr(1:3)
i = alloc_result_scalar ()
arr = alloc_result_array ()
contains
function alloc_result_scalar () result(res)
integer, allocatable :: res
allocate(res)
res = 42
end function
function alloc_result_array () result(res)
integer, dimension(:), allocatable :: res
allocate(res(1:3))
res = (/ 41, 42, 43 /)
end function
end