public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/46487] New: allocatable scalars leak memory (allocatable_scalar_5.f90)
@ 2010-11-15 15:53 burnus at gcc dot gnu.org
  2010-11-16 13:54 ` [Bug fortran/46487] " burnus at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: burnus at gcc dot gnu.org @ 2010-11-15 15:53 UTC (permalink / raw)
  To: gcc-bugs

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

           Summary: allocatable scalars leak memory
                    (allocatable_scalar_5.f90)
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: burnus@gcc.gnu.org
                CC: janus@gcc.gnu.org
            Blocks: 46485


The program allocatable_scalar_5.f90 leaks memory - even with the following
patch applied. Valgrind shows:

 LEAK SUMMARY:
    definitely lost: 8 bytes in 2 blocks

One finds twice:

 4 bytes in 1 blocks are definitely lost in loss record 1 of 2
   at 0x4C26C36: malloc (in
/usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
   by 0x400ACE: func.1538 (allocatable_scalar_5.f90:36)
   by 0x4008D1: MAIN__ (allocatable_scalar_5.f90:15)
   by 0x400B40: main (allocatable_scalar_5.f90:27)

where the crucial lines are:
    34      if (allocated (func)) call abort ()
    35      if (alloc) then
    36        allocate(func)
    37        func = 5332


Note: The following patch is needed for the test case to make it valid; cf. PR
46484


diff --git a/gcc/testsuite/gfortran.dg/allocatable_scalar_5.f90
b/gcc/testsuite/gfortran.dg/allocatable_scalar_5.f90
index cee95a1..efa40e9 100644
--- a/gcc/testsuite/gfortran.dg/allocatable_scalar_5.f90
+++ b/gcc/testsuite/gfortran.dg/allocatable_scalar_5.f90
@@ -3,3 +3,3 @@
 !
-! PR fortran/41872
+! PR fortran/41872; updated due to PR fortran/46484
 !
@@ -13,4 +13,2 @@ program test
   if (allocated (a)) call abort ()
-  if (allocated (func (.false.))) call abort ()
-  if (.not.allocated (func (.true.))) call abort ()
   b = 7
@@ -30,3 +28,2 @@ program test

-  if (allocated (func2 ())) call abort ()
 contains
@@ -43,6 +40,2 @@ contains

-  function func2 ()
-    integer, allocatable ::  func2
-  end function func2
-
   subroutine intout (dum, alloc)


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

end of thread, other threads:[~2013-08-25 14:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-11-15 15:53 [Bug fortran/46487] New: allocatable scalars leak memory (allocatable_scalar_5.f90) burnus at gcc dot gnu.org
2010-11-16 13:54 ` [Bug fortran/46487] " burnus at gcc dot gnu.org
2013-06-26 17:52 ` [Bug fortran/46487] Missing memory freeing for functions returning allocatable scalars (allocatable_scalar_5.f90) dominiq at lps dot ens.fr
2013-08-25 14:47 ` burnus 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).