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