[Bug fortran/49241] memory leak with lhs realloc of zero-sized array
burnus at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue May 31 12:47:00 GMT 2011
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49241
Tobias Burnus <burnus at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |wrong-code
CC| |burnus at gcc dot gnu.org,
| |pault at gcc dot gnu.org
--- Comment #1 from Tobias Burnus <burnus at gcc dot gnu.org> 2011-05-31 12:36:23 UTC ---
The memory the program needs increases continuously as "top" shows; it takes
about 5min on my computer before the OS kills it (out of memory).
If one does not use an endless loop but a finite loop, it shows no leakage with
neither valgrind nor totalview. Also the result seems to be fine - except that
the memory consumption simply grows ...
Slightly reduced test case:
program ala
implicit none
type :: array_of_foo
real, dimension(:), allocatable :: p
end type array_of_foo
type(array_of_foo), dimension(:), allocatable :: tab
integer :: i
do
allocate(tab(0:1))
allocate(tab(0)%p(0))
tab(1)%p = [(i,i=1,10)] ! Realloc-on assignment (fine!)
tab(0)%p = [tab(0)%p, tab(1)%p] ! << realloc-on-assignment. Culprit?
deallocate(tab)
end do
end program ala
More information about the Gcc-bugs
mailing list