Hi Mikael!

Am 25.10.26 um 11:05 AM schrieb Mikael Morin:
Le 24/10/2026 à 16:04, Harald Anlauf a écrit :
Dear all,

this follow-up patch reduces the number of front-end memleaks that pop
up during simplification of TRANSFER(), and adds the original testcase
from the PR.  The fix consists mainly of a reordering of the code in
gfc_simplify_transfer, taking into account the knowledge of the rank
of the result.

The changes to target-memory.cc could have been done differently,
but these are also sensitive to the BOZ handling.  The current
solution was the simplest one I found that does not regress.

Regression tested on x86_64-pc-linux-gnu.  OK for mainline?

Thanks,
Harald

OK modulo one small nit:
diff --git a/gcc/fortran/target-memory.cc b/gcc/fortran/target-memory.cc
index cf1bfa87950..cacb0591036 100644
--- a/gcc/fortran/target-memory.cc
+++ b/gcc/fortran/target-memory.cc
@@ -599,18 +599,25 @@ gfc_target_interpret_expr (unsigned char *buffer, size_t buffer_size,
   switch (result->ts.type)
     {
     case BT_INTEGER:
+      /* 'result->integer' is already mpz_initialized by the caller.  */
'result->value.integer'
+      mpz_clear (result->value.integer);
       result->representation.length =
         gfc_interpret_integer (result->ts.kind, buffer, buffer_size,
                    result->value.integer);
       break;


Good catch!

Fixed and pushed as r17-5555-ga88d82f24bdea7 .

Thanks for the review!

Harald

Reply via email to