https://gcc.gnu.org/bugzilla/show_bug.cgi?id=49802
--- Comment #27 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Jerry DeLisle <[email protected]>: https://gcc.gnu.org/g:a70402ecfbe753e28cd68aaf845722e62cb4316f commit r17-3650-ga70402ecfbe753e28cd68aaf845722e62cb4316f Author: Jerry DeLisle <[email protected]> Date: Sun Aug 23 18:30:26 2026 -0700 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.
