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

sandra at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |sandra at gcc dot 
gnu.org

--- Comment #8 from sandra at gcc dot gnu.org ---
In gfc_desc_to_cfi_desc (in libgfortran/runtime/ISO_Fortran_binding.c):

        /* Assumed size arrays have gfc ubound == 0 and CFI extent = -1.  */
        if (n == GFC_DESCRIPTOR_RANK (s) - 1
            && GFC_DESCRIPTOR_LBOUND(s, n) == 1
            && GFC_DESCRIPTOR_UBOUND(s, n) == 0)
          d->dim[n].extent = -1;
        else
          d->dim[n].extent = (CFI_index_t)GFC_DESCRIPTOR_UBOUND(s, n)
                             - (CFI_index_t)GFC_DESCRIPTOR_LBOUND(s, n) + 1;

The comment and test are only correct if the lower bound of the array dimension
either defaults to 1 or is explicitly specified as 1.  It does appear that the
ubound == 0 part is true, but this means e.g. an array dimension specified as
-3:* is indistinguishable from -3:0.

I think this needs to be corrected at the point where the GFC descriptor is
created; perhaps set ubound = lbound - 1?  Or also set lbound = 1 as the code
snippet above checks?  Assumed-size arrays can't be pointers or allocatable so
their bounds don't need to be preserved across calls, but maybe GFC descriptors
are used for other purposes where it matters?

Reply via email to