Le 25/08/2026 à 01:30, Jerry D a écrit :
See attached 1 of 5 patch
Regression tested on x86_64
Regards,
Jerry
---
fortran: [PR49802]-1 Add a deep copy mode to
gfc_conv_subref_array_arg
This is the shared infrastructure the rest of the PR49802 series builds
on. It changes no behaviour for any existing caller.
gfc_conv_subref_array_arg gains a DEEP_COPY argument, defaulting to
false, which it passes on to gfc_trans_scalar_assign so that the
temporary is given allocatable components of its own rather than
sharing those of the actual argument. The components are freed again
once the call has returned. Only INTENT_IN is supported, since writing
the temporary back would leave the actual argument holding the freed
component pointers.
Two latent problems in the pass_optional path are fixed at the same
time. The pointer was assigned the address of the descriptor rather
than the descriptor, and the string length was not copied back out of
the private gfc_se, so a CHARACTER actual argument reached
gfc_conv_missing_dummy with none. Neither is reachable today: the only
caller that passes SYM, and so the only one that can set pass_optional,
is gfc_conv_array_parameter, which also sets check_contiguous. Both
are exercised by the last patch of this series, where an absent
optional actual argument is passed to a VALUE dummy.
PR fortran/49802
gcc/fortran/ChangeLog:
* trans.h (gfc_conv_subref_array_arg): Add DEEP_COPY argument.
* trans-expr.cc (gfc_conv_subref_array_arg): Take DEEP_COPY and
pass it on to gfc_trans_scalar_assign; deallocate the allocatable
components of the temporary after the call. Dereference the
descriptor when setting the pointer for an optional argument that
is not also checked for contiguity, and pass the string length
back to the caller's gfc_se.
---
OK.