diff options
Diffstat (limited to 'gcc/testsuite/gfortran.dg/realloc_on_assign_15.f90')
-rw-r--r-- | gcc/testsuite/gfortran.dg/realloc_on_assign_15.f90 | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/gcc/testsuite/gfortran.dg/realloc_on_assign_15.f90 b/gcc/testsuite/gfortran.dg/realloc_on_assign_15.f90 new file mode 100644 index 000000000..2a0e5be91 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/realloc_on_assign_15.f90 @@ -0,0 +1,40 @@ +! { dg-do run } +! +! PR fortran/53389 +! +! The program was leaking memory before due to +! realloc on assignment and nested functions. +! +module foo + implicit none + contains + + function filler(array, val) + real, dimension(:), intent(in):: array + real, dimension(size(array)):: filler + real, intent(in):: val + + filler=val + + end function filler +end module + +program test + use foo + implicit none + + real, dimension(:), allocatable:: x, y + integer, parameter:: N=1000 !*1000 + integer:: i + +! allocate( x(N) ) + allocate( y(N) ) + y=0.0 + + do i=1, N +! print *,i + x=filler(filler(y, real(2*i)), real(i)) + y=y+x + end do + +end program test |