https://gcc.gnu.org/g:71451943b3946a061f460cee9e5aec20e3a957de

commit 71451943b3946a061f460cee9e5aec20e3a957de
Author: Mikael Morin <[email protected]>
Date:   Sun Nov 8 23:08:26 2026 +0100

    Correction reshape-complex

Diff:
---
 libgfortran/m4/reshape.m4 | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/libgfortran/m4/reshape.m4 b/libgfortran/m4/reshape.m4
index 4293191cdffc..14f34dab283b 100644
--- a/libgfortran/m4/reshape.m4
+++ b/libgfortran/m4/reshape.m4
@@ -58,7 +58,7 @@ reshape_'rtype_ccode` ('rtype` * const restrict ret,
   index_type rsize;
   index_type rs;
   index_type rex;
-  char *rptr;
+  'rtype_name` *rptr;
   /* s.* indicates the source array.  */
   index_type scount[GFC_MAX_DIMENSIONS];
   index_type sextent[GFC_MAX_DIMENSIONS];
@@ -66,16 +66,16 @@ reshape_'rtype_ccode` ('rtype` * const restrict ret,
   index_type sstride0;
   index_type sdim;
   index_type ssize;
-  const char *sptr;
+  const 'rtype_name` *sptr;
   /* p.* indicates the pad array.  */
   index_type pcount[GFC_MAX_DIMENSIONS];
   index_type pextent[GFC_MAX_DIMENSIONS];
   index_type pstride[GFC_MAX_DIMENSIONS];
   index_type pdim;
   index_type psize;
-  const char *pptr;
+  const 'rtype_name` *pptr;
 
-  const char *src;
+  const 'rtype_name` *src;
   int sempty, pempty, shape_empty;
   index_type shape_data[GFC_MAX_DIMENSIONS];
 
@@ -148,7 +148,7 @@ reshape_'rtype_ccode` ('rtype` * const restrict ret,
           else
             psize = 0;
         }
-      pptr = (char*) pad->base_addr;
+      pptr = pad->base_addr;
     }
   else
     {
@@ -270,8 +270,8 @@ reshape_'rtype_ccode` ('rtype` * const restrict ret,
                      ssize, pad ? (char *)pad->base_addr : NULL, psize);
       return;
     }
-  rptr = (char*) ret->base_addr;
-  src = sptr = (char*) source->base_addr;
+  rptr = ret->base_addr;
+  src = sptr = source->base_addr;
   rstride0 = rstride[0];
   sstride0 = sstride[0];
 
@@ -296,10 +296,10 @@ reshape_'rtype_ccode` ('rtype` * const restrict ret,
   while (rptr)
     {
       /* Select between the source and pad arrays.  */
-      *rptr = *src;
+      *(('rtype_name`*)rptr) = *(('rtype_name`*)src);
       /* Advance to the next element.  */
-      rptr += rstride0;
-      src += sstride0;
+      rptr = ('rtype_name` *) (((char*)rptr) + rstride0);
+      src = (const 'rtype_name` *) (((const char*)src) + sstride0);
       rcount[0]++;
       scount[0]++;
 
@@ -312,7 +312,7 @@ reshape_'rtype_ccode` ('rtype` * const restrict ret,
           rcount[n] = 0;
           /* We could precalculate these products, but this is a less
              frequently used path so probably not worth it.  */
-          rptr -= rstride[n] * rextent[n];
+          rptr = ('rtype_name` *) (((char*) rptr) + rstride[n] * rextent[n]);
           n++;
           if (n == rdim)
             {
@@ -323,7 +323,7 @@ reshape_'rtype_ccode` ('rtype` * const restrict ret,
           else
             {
               rcount[n]++;
-              rptr += rstride[n];
+              rptr = ('rtype_name` *) (((char*) rptr) + rstride[n]);
             }
         }
       /* Advance to the next source element.  */
@@ -335,7 +335,7 @@ reshape_'rtype_ccode` ('rtype` * const restrict ret,
           scount[n] = 0;
           /* We could precalculate these products, but this is a less
              frequently used path so probably not worth it.  */
-          src -= sstride[n] * sextent[n];
+          src = (const 'rtype_name` *) (((const char*) src) + sstride[n] * 
sextent[n]);
           n++;
           if (n == sdim)
             {
@@ -359,7 +359,7 @@ reshape_'rtype_ccode` ('rtype` * const restrict ret,
           else
             {
               scount[n]++;
-              src += sstride[n];
+              src = (const 'rtype_name` *) (((const char*) src) + sstride[n]);
             }
         }
     }

Reply via email to