public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "thomas.jourdan at orange dot fr" <gcc-bugzilla@gcc.gnu.org>
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	[thread overview]
Message-ID: <bug-58058-4@http.gcc.gnu.org/bugzilla/> (raw)

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


             reply	other threads:[~2013-08-02 11:35 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-02 11:35 thomas.jourdan at orange dot fr [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-58058-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).