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

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
2224      /* Now se.expr contains an element of the array.  Take the address
and pass
2225         it to the IO routines.  */
2226      tmp = gfc_build_addr_expr (NULL_TREE, se.expr);
2227      transfer_expr (&se, &cm->ts, tmp, NULL, NULL_TREE);
so code is NULL in some cases.

--- gcc/fortran/trans-io.cc.jj  2026-01-08 09:44:44.078248379 +0100
+++ gcc/fortran/trans-io.cc     2026-03-11 15:33:59.334057907 +0100
@@ -2513,7 +2513,9 @@ transfer_expr (gfc_se * se, gfc_typespec

                  if (c->attr.dimension)
                    {
-                     tmp = transfer_array_component (tmp, c, & code->loc);
+                     tmp = transfer_array_component (tmp, c,
+                                                     code ? &code->loc
+                                                     : NULL);
                      gfc_add_expr_to_block (&se->pre, tmp);
                    }
                  else
would fix this (but I'm really surprised the tons of other code dereferences
don't trigger,
          if (derived->attr.has_dtio_procs)
            arg2 = get_dtio_proc (ts, code, &dtio_sub);
which dereferences it at the start of get_dtio_proc,
                gfc_conv_derived_to_class (se, code->expr1,
                                           dtio_sub->formal->sym, vptr, false,
                                           false, "transfer");
or the earlier
  if (ts->type == BT_VOID
      && code->expr1 && code->expr1->ts.type == BT_VOID

Reply via email to