public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/55789] New: Needless realloc
@ 2012-12-22 16:23 Joost.VandeVondele at mat dot ethz.ch
  2012-12-22 18:25 ` [Bug fortran/55789] " burnus at gcc dot gnu.org
                   ` (18 more replies)
  0 siblings, 19 replies; 20+ messages in thread
From: Joost.VandeVondele at mat dot ethz.ch @ 2012-12-22 16:23 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55789

             Bug #: 55789
           Summary: Needless realloc
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: Joost.VandeVondele@mat.ethz.ch


In trying to understand some memory leak reported by mtrace (which turns out, I
think, to be a bug in glibc 
http://sourceware.org/bugzilla/show_bug.cgi?id=14981), I noticed that the
following code

MODULE M1
CONTAINS
  SUBROUTINE cp_1d_i4_sort(arr)
      INTEGER(kind=4), DIMENSION(:), &
        INTENT(inout)                          :: arr
      arr = (/ (i, i = 1, SIZE(arr)) /)
  END SUBROUTINE
END MODULE M1

PROGRAM TEST
  USE M1
  INTEGER :: arr(1)
  INTERFACE
    SUBROUTINE mtrace() BIND(C,name="mtrace")
    END SUBROUTINE
  END INTERFACE
  INTERFACE
    SUBROUTINE muntrace() BIND(C,name="muntrace")
    END SUBROUTINE
  END INTERFACE
  CALL mtrace()
  CALL cp_1d_i4_sort(arr)
  CALL muntrace()
END

performs both an allocate and a reallocate in cp_1d_i4_sort.

While I understand that a temporary is generated... something seems
inconsistent with the size computed, and the reallocate triggers. This seems
needlessly inefficient.

There seem to be some vaguely related issues.

1) a glibc mtrace bug is triggered by having a zero sized array as an argument.
In this case the realloc is zero sized, which might be equivalent to a free
(also that appears to be not un-controversial, seemingly some difference betwee
n C99 and glibc)

2) there is http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49241 which is a memory
leak in a similar situation.


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

end of thread, other threads:[~2014-05-25 15:35 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-12-22 16:23 [Bug fortran/55789] New: Needless realloc Joost.VandeVondele at mat dot ethz.ch
2012-12-22 18:25 ` [Bug fortran/55789] " burnus at gcc dot gnu.org
2013-01-01 14:25 ` [Bug fortran/55789] [4.6/4.7/4.8 Regression] Needless realloc with array constructor tkoenig at gcc dot gnu.org
2013-01-07 15:41 ` rguenth at gcc dot gnu.org
2013-01-12 16:05 ` pault at gcc dot gnu.org
2013-01-16 22:06 ` burnus at gcc dot gnu.org
2013-01-27  7:09 ` pault at gcc dot gnu.org
2013-01-27  7:38 ` pault at gcc dot gnu.org
2013-02-05  9:14 ` hubicka at gcc dot gnu.org
2013-02-05 15:24 ` hubicka at gcc dot gnu.org
2013-02-06 20:21 ` pault at gcc dot gnu.org
2013-02-06 20:30 ` [Bug fortran/55789] [4.6/4.7 " pault at gcc dot gnu.org
2013-02-07 10:45 ` jakub at gcc dot gnu.org
2013-02-08 11:31 ` jakub at gcc dot gnu.org
2013-03-02 17:22 ` mikael at gcc dot gnu.org
2013-04-12 15:17 ` [Bug fortran/55789] [4.7 " jakub at gcc dot gnu.org
2013-07-28 14:14 ` pault at gcc dot gnu.org
2014-04-06 21:02 ` dominiq at lps dot ens.fr
2014-05-24 15:45 ` dominiq at gcc dot gnu.org
2014-05-25 15:35 ` dominiq at lps dot ens.fr

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).