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: unassig...@gcc.gnu.org
        ReportedBy: bur...@gcc.gnu.org
                CC: ja...@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)

Reply via email to