Le 25/08/2026 à 01:38, Jerry D a écrit :
See attached 5 of 5 patch

Regression tested on x86_64

Regards,

Jerry

---

fortran: [PR49802]-5 Absent optional actual argument
  passed to a VALUE dummy

The private copy made for a VALUE dummy dereferenced the actual
argument unconditionally, so passing an absent optional actual argument
to an optional VALUE dummy segfaulted.  Both the array copy and the
copy made for a CHARACTER dummy of assumed or non-constant length have
to be suppressed when the actual argument is absent.

gfc_conv_subref_array_arg already has the machinery: given the symbol
of the actual argument it suppresses its copy and passes a null pointer
instead, so the array case just has to hand it that symbol rather than
the symbol of the procedure being called.  This is what makes the two
pass_optional fixes of the first patch of this series reachable.
conv_dummy_value has no such machinery and guards its CHARACTER copy
directly, passing a null pointer and a zero length when the actual
argument is absent.

     PR fortran/49802

gcc/fortran/ChangeLog:

     * trans-expr.cc (conv_dummy_value): Suppress the CHARACTER copy
     and pass a null pointer and a zero length when the actual argument
     is an absent optional one.
     (gfc_conv_procedure_call): Give gfc_conv_subref_array_arg the
     symbol of the actual argument, so that an absent optional one
     suppresses the copy.

gcc/testsuite/ChangeLog:

     * gfortran.dg/value_18.f90: New test.
---
OK.

Reply via email to