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

--- Comment #2 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Mikael Morin <[email protected]>:

https://gcc.gnu.org/g:fbc358491eac26f6680d738c59c9ce62564988f6

commit r17-3254-gfbc358491eac26f6680d738c59c9ce62564988f6
Author: Mikael Morin <[email protected]>
Date:   Thu Aug 13 09:40:14 2026 +0200

    fortran: Fix element size in collective subroutines implementation
[PR126799]

    The shared memory implementation of collective subroutines uses the array
    descriptor span as element size.  This gives a bigger value than the true
    size in some cases, as demonstrated in the testcase with a pointer pointing
    to an array subreference.  The bigger size estimate doesn't only cause
    over allocation of memory.  As the packing and unpacking functions don't
    have the same problem, they initialize and copy back only a part of the
    allocated buffer, and their element indexing in the buffer doesn't match
    that of the collective subroutine, causing wrong values to be produced.

            PR fortran/126799

    libgfortran/ChangeLog:

            * caf/shmem/collective_subroutine.c (collsub_reduce_array): Use
            the element length field instead of the span field as element size.

    gcc/testsuite/ChangeLog:

            * gfortran.dg/coarray/collectives_5.f90: New test.

Reply via email to