Hi Andre,
On 5/28/24 14:10, Andre Vehreschild wrote:
Hi all,
the attached patch fixes a memory leak with unlimited polymorphic return types.
The leak occurred, because an expression with side-effects was evaluated twice.
I have substituted the check for non-variable expressions followed by creating a
SAVE_EXPR with checking for trees with side effects and creating temp. variable
and freeing the memory.
this looks good to me. It also solves the runtime memory leak in
testcase pr114012.f90 . Nice!
Btw, I do not get the SAVE_EXPR in the old code. Is there something missing to
manifest it or is a SAVE_EXPR not meant to be evaluated twice?
I was assuming that the comment in gcc/tree.h applies here:
/* save_expr (EXP) returns an expression equivalent to EXP
but it can be used multiple times within context CTX
and only evaluate EXP once. */
I do not know what the practical difference between a SAVE_EXPR
and a temporary explicitly evaluated once (which you have now)
is, except that you can free the temporary cleanly.
Anyway, regtested ok on Linux-x86_64-Fedora_39. Ok for master?
Yes, this is fine from my side. If you are inclined to backport
to e.g. 14-branch after a grace period, that would be great.
This work is funded by the Souvereign Tech Fund. Yes, the funding has been
granted and Nicolas, Mikael and me will be working on some Fortran topics in
the next 12-18 months.
This is really great news!
Regards,
Andre
Thanks for the patch!
Harald
--
Andre Vehreschild * Email: vehre ad gmx dot de