public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/66082] New: [4.9.2/5.1.0/6.0.0] memory leak: automatic array with derived type array constructor actual argument
@ 2015-05-09  0:59 damian at sourceryinstitute dot org
  2015-05-23 11:02 ` [Bug fortran/66082] memory leak with automatic array dummy argument " pault at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: damian at sourceryinstitute dot org @ 2015-05-09  0:59 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66082

            Bug ID: 66082
           Summary: [4.9.2/5.1.0/6.0.0] memory leak: automatic array with
                    derived type array constructor actual argument
           Product: gcc
           Version: 6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: damian at sourceryinstitute dot org
  Target Milestone: ---

The code below demonstrates a memory leak generated by an automatic array dummy
argument with a corresponding actual argument that is a derived type array
constructor with an allocatable component.  Changing the dummy argument
declaration "foo(n)" to an assumed shape array "foo(:)" eliminates the leak.

Damian

$ cat reduced.f90 
  type foo_t
     real, allocatable :: bigarr
  end type 
  block
    type(foo_t) :: foo 
    allocate(foo%bigarr) 
    call foo_1d(1,[foo]) ! definitely lost
  end block
contains
  subroutine foo_1d(n,foo)
    integer n
    type(foo_t) :: foo(n)
  end subroutine 
end 
$ gfortran reduced.f90 
$ valgrind ./a.out
==7891== Memcheck, a memory error detector
==7891== Copyright (C) 2002-2011, and GNU GPL'd, by Julian Seward et al. 
==7891== Using Valgrind-3.7.0 and LibVEX; rerun with -h for copyright info
==7891== Command: ./a.out
==7891== 
==7891== 
==7891== HEAP SUMMARY:
==7891==     in use at exit: 4 bytes in 1 blocks
==7891==   total heap usage: 26 allocs, 25 frees, 12,662 bytes allocated
==7891== 
==7891== LEAK SUMMARY:
==7891==    definitely lost: 4 bytes in 1 blocks
==7891==    indirectly lost: 0 bytes in 0 blocks
==7891==      possibly lost: 0 bytes in 0 blocks
==7891==    still reachable: 0 bytes in 0 blocks
==7891==         suppressed: 0 bytes in 0 blocks
==7891== Rerun with --leak-check=full to see details of leaked memory
==7891== 
==7891== For counts of detected and suppressed errors, rerun with: -v
==7891== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 2 from 2)
$ gfortran --version
GNU Fortran (GCC) 6.0.0 20150503 (experimental)


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2015-10-18 12:24 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-09  0:59 [Bug fortran/66082] New: [4.9.2/5.1.0/6.0.0] memory leak: automatic array with derived type array constructor actual argument damian at sourceryinstitute dot org
2015-05-23 11:02 ` [Bug fortran/66082] memory leak with automatic array dummy argument " pault at gcc dot gnu.org
2015-05-23 12:31 ` mikael at gcc dot gnu.org
2015-05-26 10:21 ` pault at gcc dot gnu.org
2015-06-13  0:01 ` damian at sourceryinstitute dot org
2015-08-04 20:15 ` mikael at gcc dot gnu.org
2015-10-18 12:24 ` pault at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).