PR target/83368
[official-gcc.git] / gcc / testsuite / gfortran.dg / realloc_on_assign_15.f90
blob2a0e5be91011da4f6d80ab5ebb342d5c3d083d32
1 ! { dg-do run }
3 ! PR fortran/53389
5 ! The program was leaking memory before due to
6 ! realloc on assignment and nested functions.
8 module foo
9 implicit none
10 contains
12 function filler(array, val)
13 real, dimension(:), intent(in):: array
14 real, dimension(size(array)):: filler
15 real, intent(in):: val
17 filler=val
19 end function filler
20 end module
22 program test
23 use foo
24 implicit none
26 real, dimension(:), allocatable:: x, y
27 integer, parameter:: N=1000 !*1000
28 integer:: i
30 ! allocate( x(N) )
31 allocate( y(N) )
32 y=0.0
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
40 end program test