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

commit c08d5420cfdaa60c23a91b2bb2915277a7bb6918
Author: Mikael Morin <[email protected]>
Date:   Sat Sep 13 21:07:09 2025 +0200

    Retour en arrière partiel eoshift0.c

Diff:
---
 libgfortran/intrinsics/eoshift0.c | 33 ++++++++++++++++-----------------
 1 file changed, 16 insertions(+), 17 deletions(-)

diff --git a/libgfortran/intrinsics/eoshift0.c 
b/libgfortran/intrinsics/eoshift0.c
index 00f75f9a4b1a..3baa966398cb 100644
--- a/libgfortran/intrinsics/eoshift0.c
+++ b/libgfortran/intrinsics/eoshift0.c
@@ -63,21 +63,24 @@ eoshift0 (gfc_array_char * ret, const gfc_array_char * 
array,
 
   if (ret->base_addr == NULL)
     {
-      index_type cnt;
       int i;
 
       ret->offset = 0;
       GFC_DTYPE_COPY(ret,array);
-      cnt = 1;
       for (i = 0; i < GFC_DESCRIPTOR_RANK (array); i++)
         {
-         index_type ub;
+         index_type ub, str;
 
           ub = GFC_DESCRIPTOR_EXTENT(array,i) - 1;
 
-         GFC_DESCRIPTOR_DIMENSION_SET(ret, i, 0, ub, cnt);
+          if (i == 0)
+           str = 1;
+          else
+            str = GFC_DESCRIPTOR_EXTENT(ret,i-1)
+             * GFC_DESCRIPTOR_STRIDE(ret,i-1);
+
+         GFC_DESCRIPTOR_DIMENSION_SET(ret, i, 0, ub, str);
 
-         cnt = cnt * GFC_DESCRIPTOR_EXTENT(ret,i);
         }
 
       /* xmallocarray allocates a single byte for zero size.  */
@@ -99,36 +102,31 @@ eoshift0 (gfc_array_char * ret, const gfc_array_char * 
array,
   sstride[0] = -1;
   rstride[0] = -1;
 
-  index_type contiguous_extent;
   if (which > 0)
     {
       /* Test if both ret and array are contiguous.  */
       index_type r_ex, a_ex;
-      r_ex = GFC_DESCRIPTOR_SIZE (ret);
-      a_ex = GFC_DESCRIPTOR_SIZE (array);
+      r_ex = 1;
+      a_ex = 1;
       do_blocked = true;
-      contiguous_extent = 1;
       dim = GFC_DESCRIPTOR_RANK (array);
       for (n = 0; n < dim; n ++)
        {
          index_type rs, as;
-         rs = GFC_DESCRIPTOR_STRIDE_BYTES (ret, n);
+         rs = GFC_DESCRIPTOR_STRIDE (ret, n);
          if (rs != r_ex)
            {
              do_blocked = false;
              break;
            }
-         as = GFC_DESCRIPTOR_STRIDE_BYTES (array, n);
+         as = GFC_DESCRIPTOR_STRIDE (array, n);
          if (as != a_ex)
            {
              do_blocked = false;
              break;
            }
          r_ex *= GFC_DESCRIPTOR_EXTENT (ret, n);
-
-         index_type extent = GFC_DESCRIPTOR_EXTENT (array, n);
-         a_ex *= extent;
-         contiguous_extent *= extent;
+         a_ex *= GFC_DESCRIPTOR_EXTENT (array, n);
        }
     }
   else
@@ -149,8 +147,9 @@ eoshift0 (gfc_array_char * ret, const gfc_array_char * 
array,
         bn = eoshift(a,sh*n1*n2,1)
 
         so a block move can be used for dim>1.  */
-      len = contiguous_extent * GFC_DESCRIPTOR_EXTENT(array, which);
-      shift *= contiguous_extent;
+      index_type count_low = GFC_DESCRIPTOR_STRIDE(array, which);
+      len = count_low * GFC_DESCRIPTOR_EXTENT(array, which);
+      shift *= count_low;
       roffset = size;
       soffset = size;
       for (dim = which + 1; dim < GFC_DESCRIPTOR_RANK (array); dim++)

Reply via email to