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

--- Comment #8 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:5e8f400f12c27a5c8c0bacc6ac5975c94274db1e

commit r17-3954-g5e8f400f12c27a5c8c0bacc6ac5975c94274db1e
Author: Jerry DeLisle <[email protected]>
Date:   Tue Sep 1 10:50:00 2026 -0700

    libgfortran: [PR126964] Compare the elements a descriptor denotes in
ASSOCIATED

    The stride of a descriptor counts spans rather than elements, so two
    descriptors can denote the same storage sequence while holding different
    combinations of the two.  Elements that are subobjects of larger ones are
    described either by the spacing of the larger objects as the span, with the
    stride counting them, or by that spacing folded into the stride, with the
    element length as the span.  ASSOCIATED compared the span and the strides
    field by field, so a pointer to a dummy whose spacing is folded into its
    strides on entry was not associated with its own actual argument.

    Compare the stride in bytes, which is what the two encodings have in
    common.  The element length is normally held by the dtype, but the
    descriptor built for a polymorphic pointer to a character section holds
    the spacing there instead and carries the length separately, so require
    the two to agree on the element length or on the span rather than on the
    element length alone.

    Assisted-by: Claude Opus 5

            PR fortran/126964

    libgfortran/ChangeLog:

            * intrinsics/associated.c (stride_in_bytes): New function.
            (associated): Require the element length or the span to agree
            rather than the span alone, and compare the stride in bytes
            rather than the stride.

    gcc/testsuite/ChangeLog:

            * gfortran.dg/associated_target_9.f90: New test.

Reply via email to