public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "pault at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/66082] memory leak with automatic array dummy argument with derived type array constructor actual argument
Date: Sat, 23 May 2015 11:02:00 -0000	[thread overview]
Message-ID: <bug-66082-4-7AFdTfeLmO@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-66082-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66082

Paul Thomas <pault at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2015-05-23
                 CC|                            |pault at gcc dot gnu.org
           Assignee|unassigned at gcc dot gnu.org      |pault at gcc dot gnu.org
     Ever confirmed|0                           |1

--- Comment #1 from Paul Thomas <pault at gcc dot gnu.org> ---
Confirmed.

Oddly, the memory leak goes away at any level of optimization. What makes this
odd is that the assumed shape array case has all the code for deallocation of
the allocatable component after the call to foo_1d:

          foo_1d (&C.3401, &atmp.3);
          if ((struct foo_t[1] * restrict) atmp.3.data != 0B)
            {
              D.3411 = (atmp.3.dim[0].ubound - atmp.3.dim[0].lbound) + 1;
              D.3412 = atmp.3.dim[0].stride * D.3411;
              D.3413 = D.3412 + -1;
              S.6 = 0;
              while (1)
                {
                  if (S.6 > D.3413) goto L.3;
                  if ((*(struct foo_t[1] * restrict) atmp.3.data)[S.6].bigarr
!= 0B)
                    {
                      __builtin_free ((void *) (*(struct foo_t[1] * restrict)
atmp.3.data)[S.6].bigarr);
                    }
                  (*(struct foo_t[1] * restrict) atmp.3.data)[S.6].bigarr = 0B;
                  S.6 = S.6 + 1;
                }
              L.3:;
            }

and this disappears completely for the automatic array dummy. I am pretty sure
that ther problem lies in trans-array.c(gfc_conv_array_parameter), where the
deallocation of allocatable components appears after the return for g77 style
dummies. I cannot check this right now because I am doing a fresh bootstrap
with a clean tree.

Paul


  reply	other threads:[~2015-05-23 11:02 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-09  0:59 [Bug fortran/66082] New: [4.9.2/5.1.0/6.0.0] memory leak: automatic array " damian at sourceryinstitute dot org
2015-05-23 11:02 ` pault at gcc dot gnu.org [this message]
2015-05-23 12:31 ` [Bug fortran/66082] memory leak with automatic array dummy argument " mikael at gcc dot gnu.org
2015-05-26 10:21 ` pault at gcc dot gnu.org
2015-06-13  0:01 ` damian at sourceryinstitute dot org
2015-08-04 20:15 ` mikael at gcc dot gnu.org
2015-10-18 12:24 ` pault 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-66082-4-7AFdTfeLmO@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).