From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9163 invoked by alias); 15 Nov 2010 15:46:36 -0000 Received: (qmail 9147 invoked by uid 22791); 15 Nov 2010 15:46:34 -0000 X-SWARE-Spam-Status: No, hits=-2.8 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 15 Nov 2010 15:45:48 +0000 From: "burnus at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/46487] New: allocatable scalars leak memory (allocatable_scalar_5.f90) X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: burnus at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Date: Mon, 15 Nov 2010 15:53:00 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2010-11/txt/msg01939.txt.bz2 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)