1! { dg-do run }
2!
3! PR fortran/53389
4!
5! The program was leaking memory before due to
6! realloc on assignment and nested functions.
7!
8module foo
9  implicit none
10  contains
11
12  function filler(array, val)
13    real, dimension(:), intent(in):: array
14    real, dimension(size(array)):: filler
15    real, intent(in):: val
16
17    filler=val
18
19  end function filler
20end module
21
22program test
23  use foo
24  implicit none
25
26  real, dimension(:), allocatable:: x, y
27  integer, parameter:: N=1000 !*1000
28  integer:: i
29
30!  allocate( x(N) )
31  allocate( y(N) )
32  y=0.0
33
34  do i=1, N
35!    print *,i
36    x=filler(filler(y, real(2*i)), real(i))
37    y=y+x
38  end do
39
40end program test
41