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

--- Comment #14 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-13 branch has been updated by Paul Thomas <[email protected]>:

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

commit r13-10304-gc5ddbb5342e2926ccda04c084bb20e458cef9232
Author: Christopher Albert <[email protected]>
Date:   Sun Mar 29 20:52:26 2026 +0200

    fortran: Fix ICE in gfc_trans_auto_array_allocation with scalar coarray
[PR93715]

    A scalar coarray variable (e.g. integer :: b[*]) used in asynchronous
    I/O causes an ICE in gfc_trans_auto_array_allocation because the
    variable reaches gfc_trans_auto_array_allocation which asserts
    GFC_ARRAY_TYPE_P on the backend declaration type.  For scalar coarrays,
    the backend type is a plain scalar, not a GFC array type.

    The root cause is in gfc_trans_deferred_vars: scalar coarray variables
    enter the AS_EXPLICIT case because sym->attr.codimension is set and the
    coarray spec type is AS_EXPLICIT.  The existing guard for static coarray
    variables does not catch non-static scalar coarrays, so they fall
    through to gfc_trans_auto_array_allocation.

    Add a check for scalar coarrays (codimension without dimension) to skip
    array allocation, since these variables have no array rank and do not
    need auto array allocation.

    2026-04-08  Paul Thomas  <[email protected]>

            PR fortran/93715

    gcc/fortran

            * trans-decl.cc (gfc_trans_deferred_vars): Skip auto array
            allocation for scalar coarrays.

    gcc/testsuite

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

    Signed-off-by: Christopher Albert <[email protected]>
    (cherry picked from commit 2b0a29a94c9946e32cf76f4f65da368b4f005566)

Reply via email to