[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gcc-bugs
Subject:    [Bug fortran/49241] memory leak with lhs realloc of zero-sized array
From:       "xarthisius.kk at gmail dot com" <gcc-bugzilla () gcc ! gnu ! org>
Date:       2011-05-31 15:13:35
Message-ID: bug-49241-4-PfYhnh8qea () http ! gcc ! gnu ! org/bugzilla/
[Download RAW message or body]

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49241

--- Comment #2 from Kacper Kowalik <xarthisius.kk at gmail dot com> 2011-05-31 15:12:19 UTC ---
(In reply to comment #1)
> 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:
It's not caused by reallocation, rather by array constructor? 
Test case without lhs realloc:

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, nn

   do
      allocate(tab(1:2))
      allocate(tab(1)%p(0))
      allocate(tab(2)%p(1))
      tab(2)%p(1) = 1.0

      nn = size( [tab(1)%p, tab(2)%p] )

      deallocate(tab(2)%p)
      deallocate(tab(1)%p)
      deallocate(tab)
   end do
end program ala
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic