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

--- Comment #12 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> ---
The following additional patch from Harald posted on the gfortran list:

https://gcc.gnu.org/pipermail/fortran/2024-December/061452.html

diff --git a/gcc/fortran/trans-intrinsic.cc b/gcc/fortran/trans-intrinsic.cc
index 2370b6dad55..886f999f206 100644
--- a/gcc/fortran/trans-intrinsic.cc
+++ b/gcc/fortran/trans-intrinsic.cc
@@ -10220,6 +10220,16 @@ conv_isocbinding_function (gfc_se *se, gfc_expr
*expr)

          gfc_init_se (&asis_se, se);
          gfc_conv_expr (&asis_se, asis);
+         if (asis->expr_type == EXPR_VARIABLE
+             && asis->symtree->n.sym->attr.dummy
+             && asis->symtree->n.sym->attr.optional)
+           {
+             tree present = gfc_conv_expr_present (asis->symtree->n.sym);
+             asis_se.expr = build3_loc (input_location, COND_EXPR,
+                                        logical_type_node, present,
+                                        asis_se.expr,
+                                        build_int_cst
(logical_type_node, 0));
+           }
          gfc_add_block_to_block (&se->pre, &asis_se.pre);
          tmp = fold_build3_loc (input_location, COND_EXPR,
void_type_node,
                                 asis_se.expr, then_branch, else_branch);

I will put this altogether in one patch. 

Steve, any further comments?

Reply via email to