From: Paul Richard Thomas <paul.richard.thomas@gmail.com>
To: Harald Anlauf <anlauf@gmx.de>
Cc: Mikael Morin <morin-mikael@orange.fr>,
"fortran@gcc.gnu.org" <fortran@gcc.gnu.org>,
gcc-patches <gcc-patches@gcc.gnu.org>
Subject: Re: [Patch, fortran] PR87477 - (associate) - [meta-bug] [F03] issues concerning the ASSOCIATE statement
Date: Thu, 8 Jun 2023 10:11:51 +0100 [thread overview]
Message-ID: <CAGkQGiKr0MNwc4WT2gFM5KLy+DMvA3oCAWyaiA+=ns67C1AV_Q@mail.gmail.com> (raw)
In-Reply-To: <c78cacaa-a6e3-d224-6d7f-511137780b2a@gmx.de>
Thanks Gents!
The solution is to gfc_free_expr (p) if the replacement is not made.
I am regtesting a patch for PR107900. I'll include the fix for the
memory leak in the patch for that.
Cheers
Paul
On Thu, 8 Jun 2023 at 09:30, Harald Anlauf <anlauf@gmx.de> wrote:
>
> On 6/8/23 09:46, Mikael Morin wrote:
> > Le 08/06/2023 à 07:57, Paul Richard Thomas via Fortran a écrit :
> >> Hi Harald,
> >>
> >> In answer to your question:
> >> void
> >> gfc_replace_expr (gfc_expr *dest, gfc_expr *src)
> >> {
> >> free_expr0 (dest);
> >> *dest = *src;
> >> free (src);
> >> }
> >> So it does indeed do the job.
> >>
> > Sure, but his comment was about the case gfc_replace_expr is *not*
> > executed.
>
> Right. The following legal code exhibits the leak, pointing
> to the gfc_copy_expr:
>
> subroutine paul (n)
> integer :: n
> character(n) :: c
> end
>
> >> I should perhaps have remarked that, following the divide error,
> >> gfc_simplify_expr was returning a mutilated version of the expression
> >> and this was somehow connected with successfully simplifying the
> >> parentheses. Copying and replacing on no errors deals with the
> >> problem.
> >>
> > Is the expression mutilated enough that it can't be safely freed?
> >
> >
> >
>
--
"If you can't explain it simply, you don't understand it well enough"
- Albert Einstein
prev parent reply other threads:[~2023-06-08 9:12 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-07 16:10 Paul Richard Thomas
2023-06-07 18:38 ` Harald Anlauf
2023-06-08 5:57 ` Paul Richard Thomas
2023-06-08 7:46 ` Mikael Morin
2023-06-08 8:30 ` Harald Anlauf
2023-06-08 9:11 ` Paul Richard Thomas [this message]
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='CAGkQGiKr0MNwc4WT2gFM5KLy+DMvA3oCAWyaiA+=ns67C1AV_Q@mail.gmail.com' \
--to=paul.richard.thomas@gmail.com \
--cc=anlauf@gmx.de \
--cc=fortran@gcc.gnu.org \
--cc=gcc-patches@gcc.gnu.org \
--cc=morin-mikael@orange.fr \
/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).