Message ID | trinity-c1e9f326-6050-46da-95bb-a78fde011492-1723577131135@3c-app-gmx-bap09 |
---|---|
State | New |
Headers | show |
Series | Fortran: fix minor frontend GMP leaks | expand |
Hi Harald, I had a hard time to figure why this is correct, when gfc_array_size() returned false, but now I get it. Ok to commit. - Andre On Tue, 13 Aug 2024 21:25:31 +0200 Harald Anlauf <anlauf@gmx.de> wrote: > Dear all, > > while running f951 under valgrind on testcase gfortran.dg/sizeof_6.f90 > I found two minor memleaks with GMP variables that were not cleared. > > Regtested on x86_64-pc-linux-gnu. > > I intend to commit to mainline soon unless there are comments. > > (And no, this does not address the recent intermittent runtime failures > reported in pr116261). > > Thanks, > Harald > -- Andre Vehreschild * Email: vehre ad gmx dot de
Hi Andre, Am 14.08.24 um 07:53 schrieb Andre Vehreschild: > Hi Harald, > > I had a hard time to figure why this is correct, when gfc_array_size() returned > false, but now I get it. Ok to commit. I know that reading code is always twice as hard as writing it... ;-) Thanks for checking. Pushed as r15-2917-ga82c4dfe52dac3 . Harald > - Andre > > On Tue, 13 Aug 2024 21:25:31 +0200 > Harald Anlauf <anlauf@gmx.de> wrote: > >> Dear all, >> >> while running f951 under valgrind on testcase gfortran.dg/sizeof_6.f90 >> I found two minor memleaks with GMP variables that were not cleared. >> >> Regtested on x86_64-pc-linux-gnu. >> >> I intend to commit to mainline soon unless there are comments. >> >> (And no, this does not address the recent intermittent runtime failures >> reported in pr116261). >> >> Thanks, >> Harald >> > > > -- > Andre Vehreschild * Email: vehre ad gmx dot de >
From 0cef868a87050c9854ac17c5a604c1aa72ea1862 Mon Sep 17 00:00:00 2001 From: Harald Anlauf <anlauf@gmx.de> Date: Tue, 13 Aug 2024 21:17:45 +0200 Subject: [PATCH] Fortran: fix minor frontend GMP leaks gcc/fortran/ChangeLog: * simplify.cc (gfc_simplify_sizeof): Clear used gmp variable. * target-memory.cc (gfc_target_expr_size): Likewise. --- gcc/fortran/simplify.cc | 10 +++++++--- gcc/fortran/target-memory.cc | 2 ++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/gcc/fortran/simplify.cc b/gcc/fortran/simplify.cc index 8ddd491de11..953d59efd70 100644 --- a/gcc/fortran/simplify.cc +++ b/gcc/fortran/simplify.cc @@ -7778,9 +7778,13 @@ gfc_simplify_sizeof (gfc_expr *x) || x->ts.u.cl->length->expr_type != EXPR_CONSTANT)) return NULL; - if (x->rank && x->expr_type != EXPR_ARRAY - && !gfc_array_size (x, &array_size)) - return NULL; + if (x->rank && x->expr_type != EXPR_ARRAY) + { + if (!gfc_array_size (x, &array_size)) + return NULL; + + mpz_clear (array_size); + } result = gfc_get_constant_expr (BT_INTEGER, gfc_index_integer_kind, &x->where); diff --git a/gcc/fortran/target-memory.cc b/gcc/fortran/target-memory.cc index a02db7a06e4..0a289f32d37 100644 --- a/gcc/fortran/target-memory.cc +++ b/gcc/fortran/target-memory.cc @@ -158,6 +158,8 @@ gfc_target_expr_size (gfc_expr *e, size_t *size) asz = mpz_get_ui (tmp); else return false; + + mpz_clear (tmp); } else asz = 1; -- 2.35.3