[committed] Fortran: fix memory leak with real to integer conversion warning
Checks
Commit Message
Dear all,
while checking f951 for memory leaks on testcases that appeared
relevant during work on pr108924, I found that the conversion
warning triggered by do_subscript_6.f90 uses a code path that
forgot to mpfr_clear a used variable.
The attached obvious patch fixes this - verified by valgrind.
Pushed to mainline as r13-6344-g03c60e525bea13 .
Thanks,
Harald
From 03c60e525bea13c15edd2f64cd582f168fe80bfb Mon Sep 17 00:00:00 2001
From: Harald Anlauf <anlauf@gmx.de>
Date: Sat, 25 Feb 2023 19:05:38 +0100
Subject: [PATCH] Fortran: fix memory leak with real to integer conversion
warning
gcc/fortran/ChangeLog:
* arith.cc (gfc_real2int): Clear mpfr variable after use.
---
gcc/fortran/arith.cc | 1 +
1 file changed, 1 insertion(+)
@@ -2257,6 +2257,7 @@ gfc_real2int (gfc_expr *src, int kind)
gfc_typename (&result->ts), &src->where);
did_warn = true;
}
+ mpfr_clear (f);
}
if (!did_warn && warn_conversion_extra)
{
--
2.35.3