https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110360

--- Comment #41 from anlauf at gcc dot gnu.org ---
(In reply to Mikael Morin from comment #40)
> Harald, I have just closed the followup PR110419.
> I think this PR can be closed as well, or is there something left to be done?

It is pretty much done.

There is a minor memleak for the bind(c) case left that can be seen for
testcase gfortran.dg/bind_c_usage_13.f03 or the reduced version:

program p
  interface
     subroutine val_c (c) bind(c)
       use iso_c_binding, only: c_char
       character(len=1,kind=c_char), value :: c
     end subroutine val_c
  end interface
  call val_c ("A")
end

The leak is plugged by the first part of the patch attached to comment#37:

diff --git a/gcc/fortran/trans-expr.cc b/gcc/fortran/trans-expr.cc
index 52cd88f5b00..ee3cd47cf91 100644
--- a/gcc/fortran/trans-expr.cc
+++ b/gcc/fortran/trans-expr.cc
@@ -4044,8 +4044,9 @@ conv_scalar_char_value (gfc_symbol *sym, gfc_se *se,
gfc_expr **expr)
       gfc_typespec ts;
       gfc_clear_ts (&ts);

-      *expr = gfc_get_int_expr (gfc_default_character_kind, NULL,
-                               (*expr)->value.character.string[0]);
+      gfc_expr *tmp = gfc_get_int_expr (gfc_default_character_kind, NULL,
+                                       (*expr)->value.character.string[0]);
+      gfc_replace_expr (*expr, tmp);
     }
   else if (se != NULL && (*expr)->expr_type == EXPR_VARIABLE)
     {

Shall we commit this one?

Reply via email to