public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/58058] New: Memory leak with transfer function
@ 2013-08-02 11:35 thomas.jourdan at orange dot fr
  2013-08-02 14:18 ` [Bug fortran/58058] [4.7/4.8/4.9 Regression] " janus at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: thomas.jourdan at orange dot fr @ 2013-08-02 11:35 UTC (permalink / raw)
  To: gcc-bugs

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


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

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

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-02 11:35 [Bug fortran/58058] New: Memory leak with transfer function thomas.jourdan at orange dot fr
2013-08-02 14:18 ` [Bug fortran/58058] [4.7/4.8/4.9 Regression] " janus at gcc dot gnu.org
2013-08-02 15:02 ` janus at gcc dot gnu.org
2013-08-02 16:12 ` janus at gcc dot gnu.org
2013-08-09 17:10 ` janus at gcc dot gnu.org
2013-08-11 11:32 ` janus at gcc dot gnu.org
2013-08-11 14:10 ` janus at gcc dot gnu.org
2013-08-11 14:15 ` janus 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).