PING please

On 7/30/26 10:21 AM, Jerry D wrote:
See the attached patch.

As stated in the PR we were missing the stride multiplier (ie span)

I will note as a useful tool: I had an initial patch for this but wanted to exercise it. I prompted Claude Pro Opus 5 to create numerous variations on the original test case provided by Tobias Burnus in the original report. The result was 25 to 30 variations which were helpful in identifying code paths I would not have otherwise found.  I am not using those test cases here.

I flagged out this one to work on as it has been around a long time and we were giving wrong results without any idea it was happening.

I also wanted to mention that the fortran standardese is difficult to interpret but I think I got this right.

Regression tested on x86_64.

OK for mainline?

Comments appreciated.

Regards,

Jerry
---
    fortran: [PR53800] Wrong copy-in/out with CLASS array to assumed- shape TYPE

    A CLASS array actual passed to a plain assumed-shape derived-type dummy     was always copied in and out, so pointers associated with the dummy went
     stale on return.  F2023 15.5.2.5 paragraph 9 requires the dummy to be
    associated with the actual's storage when it has the TARGET attribute and     lacks CONTIGUOUS and VALUE; paragraph 8 leaves every other case free to     use a copy.  Pass such a dummy by reference and address its elements with
     the descriptor's runtime span.

             PR fortran/53800

     gcc/fortran/ChangeLog:

             * trans-array.cc (need_span): New function.
            (gfc_get_array_span): Read the span from the saved descriptor of a
             span-array dummy, but not for a sub-array reached through a
             component.
             (gfc_conv_scalarized_array_ref): Use need_span.
             (gfc_conv_array_ref): Likewise.
             (build_array_ref): Default DECL to DESC for a span-array decl.
             * trans-decl.cc (gfc_build_dummy_array_decl): Mark a TARGET
             assumed-shape derived-type dummy as needing runtime span
             addressing, unless it is repacked.
            * trans-expr.cc (class_actual_aliases_type_dummy): New function.
             (gfc_class_array_data_assign): Also copy the span field.
            (gfc_conv_procedure_call): Use class_actual_aliases_type_dummy to             skip copy-in/copy-out for both the class array reference and the
             class array function actual argument.
            * trans.cc (get_array_span): Read the span from the dummy's saved
             descriptor for span-array decls.
             * trans.h (struct lang_decl): Add span_array bitfield.
             (GFC_DECL_SPAN_ARRAY_P): New macro.
             (GFC_DECL_GET_SPAN_ARRAY_P): New macro.

     gcc/testsuite/ChangeLog:

             * gfortran.dg/class_to_type_5.f90: New test.
             * gfortran.dg/class_to_type_6.f90: New test.


Reply via email to