From: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
To: fortran@gcc.gnu.org
Cc: rep.dot.nop@gmail.com, Harald Anlauf <anlauf@gmx.de>,
gcc-patches@gcc.gnu.org,
Bernhard Reutner-Fischer <aldot@gcc.gnu.org>,
nathan@acm.org, dmalcolm@redhat.com
Subject: Re: [PATCH 2/2] Fortran: Fix memory leak in gfc_add_include_path [PR68800]
Date: Sun, 2 Apr 2023 21:27:53 +0200 [thread overview]
Message-ID: <20230402212753.05eee653@nbbrfq> (raw)
In-Reply-To: <20211107023821.34234999@nbbrfq>
ping?
libcpp maintainers, is the helper in incpath.* ok?
fortraners,
Do you prefer a rogue, local forward declaration, or is the
introduction of that trivial wrapper ok? I don't think pulling in cpp.h
from f95-lang.cc is desirable, but i can do that if you all think
that's preferred.
cover-letter:
https://gcc.gnu.org/pipermail/gcc-patches/2021-November/583522.html
gcc/incpath.* bits (i guess that'd be for the libcpp maintainers):
https://gcc.gnu.org/pipermail/gcc-patches/2021-November/583520.html
fortran bits:
https://gcc.gnu.org/pipermail/gcc-patches/2021-November/583521.html
thanks,
On Sun, 7 Nov 2021 02:38:21 +0100
Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> wrote:
> On Sat, 6 Nov 2021 20:22:53 +0100
> Harald Anlauf <anlauf@gmx.de> wrote:
>
> > Hi Bernhard,
> >
> > I cannot comment on the gcc/ parts, but
> >
>
> > > diff --git a/gcc/fortran/cpp.c b/gcc/fortran/cpp.c
> > > index e86386c8b17..04fe8fe460b 100644
> > > --- a/gcc/fortran/cpp.c
> > > +++ b/gcc/fortran/cpp.c
> > > @@ -728,12 +728,20 @@ gfc_cpp_done (void)
> > > cpp_clear_file_cache (cpp_in);
> > > }
> >
> > why do you introduce a wrapper for something outside of fortran
> > that is used only once,
> >
> > > -/* PATH must be malloc-ed and NULL-terminated. */
> > > +/* Free all cpp include dirs. */
> > > +void
> > > +gfc_cpp_free_cpp_dirs (void)
> > > +{
> > > + free_cpp_dirs ();
> > > +}
>
> > > diff --git a/gcc/fortran/cpp.h b/gcc/fortran/cpp.h
> > > index 44644a2a333..963b9a9c89e 100644
> > > --- a/gcc/fortran/cpp.h
> > > +++ b/gcc/fortran/cpp.h
> > > @@ -46,6 +46,7 @@ void gfc_cpp_post_options (bool);
> > > bool gfc_cpp_preprocess (const char *source_file);
> > >
> > > void gfc_cpp_done (void);
> > > +void gfc_cpp_free_cpp_dirs (void);
> > >
> > > void gfc_cpp_add_include_path (char *path, bool user_supplied);
> > > void gfc_cpp_add_include_path_after (char *path, bool user_supplied);
> > > diff --git a/gcc/fortran/f95-lang.c b/gcc/fortran/f95-lang.c
> > > index 58dcaf01d75..ec4c2cf01d9 100644
> > > --- a/gcc/fortran/f95-lang.c
> > > +++ b/gcc/fortran/f95-lang.c
> > > @@ -275,7 +275,7 @@ gfc_finish (void)
> > > gfc_cpp_done ();
> > > gfc_done_1 ();
> > > gfc_release_include_path ();
> > > - return;
> >
> > namely here?
> >
> > > + gfc_cpp_free_cpp_dirs ();
> > > }
> >
> > Why not call free_cpp_dirs () here directly, omit all unnecessary
> > stuff, and maybe only add a brief comment here?
>
> cpp.c includes incpath.h, f95-lang.c does not and should not.
> So the cleanest thing is to keep the cpp handling in cpp.[ch] and have
> the language frontend call into it's cpp bits.
>
> It would be rather rogue to
> extern void free_cpp_dirs (void);
> in f95-lang.c and directly call it in gfc_finish, i'd say?
>
> thanks,
next prev parent reply other threads:[~2023-04-02 19:27 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-05 21:17 [PATCH 0/2] incpath, Fortran: Fix memory leak in gfc_add_include_path Bernhard Reutner-Fischer
2021-11-05 21:17 ` [PATCH 1/2] Add free_cpp_dirs() Bernhard Reutner-Fischer
2021-11-05 21:17 ` [PATCH 2/2] Fortran: Fix memory leak in gfc_add_include_path [PR68800] Bernhard Reutner-Fischer
2021-11-06 19:22 ` Harald Anlauf
2021-11-06 19:22 ` Harald Anlauf
2021-11-07 1:38 ` Bernhard Reutner-Fischer
2023-04-02 19:27 ` Bernhard Reutner-Fischer [this message]
2021-11-05 22:59 ` [PATCH 0/2] incpath, Fortran: Fix memory leak in gfc_add_include_path Bernhard Reutner-Fischer
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=20230402212753.05eee653@nbbrfq \
--to=rep.dot.nop@gmail.com \
--cc=aldot@gcc.gnu.org \
--cc=anlauf@gmx.de \
--cc=dmalcolm@redhat.com \
--cc=fortran@gcc.gnu.org \
--cc=gcc-patches@gcc.gnu.org \
--cc=nathan@acm.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).