From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27303 invoked by alias); 2 Aug 2013 11:35:58 -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 Received: (qmail 27239 invoked by uid 48); 2 Aug 2013 11:35:55 -0000 From: "thomas.jourdan at orange dot fr" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/58058] New: Memory leak with transfer function Date: Fri, 02 Aug 2013 11:35:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Version: 4.8.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: thomas.jourdan at orange dot fr X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2013-08/txt/msg00115.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58058 Bug ID: 58058 Summary: Memory leak with transfer function Product: gcc Version: 4.8.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: thomas.jourdan at orange dot fr Hello, Using gfortran 4.8.1, the following code runs fine but according to valgrind it produces a memory leak: program test1 implicit none integer, dimension(3) :: t1, t2 character(len=64) :: str t1 = (/1,2,3/) !str = transfer((/1,2,3/),str) ! works str = transfer(t1,str) ! memory leak t2 = transfer(str,t1) write(*,*) 't2 = ',t2 end program test1 The output is: ==7005== Memcheck, a memory error detector ==7005== Copyright (C) 2002-2012, and GNU GPL'd, by Julian Seward et al. ==7005== Using Valgrind-3.8.1 and LibVEX; rerun with -h for copyright info ==7005== Command: ./test1 ==7005== t2 = 1 2 3 ==7005== ==7005== HEAP SUMMARY: ==7005== in use at exit: 64 bytes in 1 blocks ==7005== total heap usage: 23 allocs, 22 frees, 11,897 bytes allocated ==7005== ==7005== LEAK SUMMARY: ==7005== definitely lost: 64 bytes in 1 blocks ==7005== indirectly lost: 0 bytes in 0 blocks ==7005== possibly lost: 0 bytes in 0 blocks ==7005== still reachable: 0 bytes in 0 blocks ==7005== suppressed: 0 bytes in 0 blocks ==7005== Rerun with --leak-check=full to see details of leaked memory ==7005== ==7005== For counts of detected and suppressed errors, rerun with: -v ==7005== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 2 from 2) If I use directly "str = transfer((/1,2,3/),str)" instead, no memory problem occurs. I experienced the same problem with the following test: program test2 implicit none type tuple integer :: nn integer :: pp integer :: qq end type tuple character(len=64) :: str type(tuple) :: mt1, mt2 mt1%nn = 1 mt1%pp = 2 mt1%qq = 3 str = transfer(mt1,str) mt2 = transfer(str,mt2) end program test2 Thanks, Thomas