https://gcc.gnu.org/g:22eae467619c8bfab8a50c7c90670601dbbf67fb

commit 22eae467619c8bfab8a50c7c90670601dbbf67fb
Author: Mikael Morin <mik...@gcc.gnu.org>
Date:   Tue May 20 14:20:24 2025 +0200

    Correction partielle maxval_char_4

Diff:
---
 libgfortran/generated/maxloc0_16_s1.c | 16 +++---
 libgfortran/generated/maxloc0_16_s4.c | 16 +++---
 libgfortran/generated/maxloc0_4_s1.c  | 16 +++---
 libgfortran/generated/maxloc0_4_s4.c  | 16 +++---
 libgfortran/generated/maxloc0_8_s1.c  | 16 +++---
 libgfortran/generated/maxloc0_8_s4.c  | 16 +++---
 libgfortran/generated/maxval1_s1.c    | 13 +++--
 libgfortran/generated/maxval1_s4.c    | 13 +++--
 libgfortran/generated/minloc0_16_s1.c | 16 +++---
 libgfortran/generated/minloc0_16_s4.c | 16 +++---
 libgfortran/generated/minloc0_4_s1.c  | 16 +++---
 libgfortran/generated/minloc0_4_s4.c  | 16 +++---
 libgfortran/generated/minloc0_8_s1.c  | 16 +++---
 libgfortran/generated/minloc0_8_s4.c  | 16 +++---
 libgfortran/generated/minval1_s1.c    | 13 +++--
 libgfortran/generated/minval1_s4.c    | 13 +++--
 libgfortran/m4/ifunction-s2.m4        | 99 ++++++++++++++++++-----------------
 17 files changed, 179 insertions(+), 164 deletions(-)

diff --git a/libgfortran/generated/maxloc0_16_s1.c 
b/libgfortran/generated/maxloc0_16_s1.c
index 7056d7fca55b..47697cdd3795 100644
--- a/libgfortran/generated/maxloc0_16_s1.c
+++ b/libgfortran/generated/maxloc0_16_s1.c
@@ -44,12 +44,12 @@ compare_fcn (const GFC_UINTEGER_1 *a, const GFC_UINTEGER_1 
*b, gfc_charlen_type
 
 }
 
-extern void maxloc0_16_s1 (gfc_array_i16 * const restrict retarray, 
+extern void maxloc0_16_s1 (gfc_array_i16 * const restrict retarray,
        gfc_array_s1 * const restrict array, GFC_LOGICAL_4 back, 
gfc_charlen_type len);
 export_proto(maxloc0_16_s1);
 
 void
-maxloc0_16_s1 (gfc_array_i16 * const restrict retarray, 
+maxloc0_16_s1 (gfc_array_i16 * const restrict retarray,
        gfc_array_s1 * const restrict array, GFC_LOGICAL_4 back, 
gfc_charlen_type len)
 {
   index_type count[GFC_MAX_DIMENSIONS];
@@ -151,13 +151,13 @@ maxloc0_16_s1 (gfc_array_i16 * const restrict retarray,
 }
 
 
-extern void mmaxloc0_16_s1 (gfc_array_i16 * const restrict, 
+extern void mmaxloc0_16_s1 (gfc_array_i16 * const restrict,
        gfc_array_s1 * const restrict, gfc_array_l1 * const restrict , 
GFC_LOGICAL_4 back,
        gfc_charlen_type len);
 export_proto(mmaxloc0_16_s1);
 
 void
-mmaxloc0_16_s1 (gfc_array_i16 * const restrict retarray, 
+mmaxloc0_16_s1 (gfc_array_i16 * const restrict retarray,
        gfc_array_s1 * const restrict array,
        gfc_array_l1 * const restrict mask, GFC_LOGICAL_4 back,
        gfc_charlen_type len)
@@ -176,7 +176,7 @@ mmaxloc0_16_s1 (gfc_array_i16 * const restrict retarray,
 
   if (mask == NULL)
     {
-#ifdef HAVE_BACK_ARG    
+#ifdef HAVE_BACK_ARG
       maxloc0_16_s1 (retarray, array, back, len);
 #else
       maxloc0_16_s1 (retarray, array, len);
@@ -298,13 +298,13 @@ mmaxloc0_16_s1 (gfc_array_i16 * const restrict retarray,
 }
 
 
-extern void smaxloc0_16_s1 (gfc_array_i16 * const restrict, 
+extern void smaxloc0_16_s1 (gfc_array_i16 * const restrict,
        gfc_array_s1 * const restrict, GFC_LOGICAL_4 *, GFC_LOGICAL_4 back,
        gfc_charlen_type len);
 export_proto(smaxloc0_16_s1);
 
 void
-smaxloc0_16_s1 (gfc_array_i16 * const restrict retarray, 
+smaxloc0_16_s1 (gfc_array_i16 * const restrict retarray,
        gfc_array_s1 * const restrict array,
        GFC_LOGICAL_4 * mask, GFC_LOGICAL_4 back,
        gfc_charlen_type len)
@@ -316,7 +316,7 @@ smaxloc0_16_s1 (gfc_array_i16 * const restrict retarray,
 
   if (mask == NULL || *mask)
     {
-#ifdef HAVE_BACK_ARG    
+#ifdef HAVE_BACK_ARG
       maxloc0_16_s1 (retarray, array, back, len);
 #else
       maxloc0_16_s1 (retarray, array, len);
diff --git a/libgfortran/generated/maxloc0_16_s4.c 
b/libgfortran/generated/maxloc0_16_s4.c
index 095f8a169e93..d719520688b0 100644
--- a/libgfortran/generated/maxloc0_16_s4.c
+++ b/libgfortran/generated/maxloc0_16_s4.c
@@ -44,12 +44,12 @@ compare_fcn (const GFC_UINTEGER_4 *a, const GFC_UINTEGER_4 
*b, gfc_charlen_type
 
 }
 
-extern void maxloc0_16_s4 (gfc_array_i16 * const restrict retarray, 
+extern void maxloc0_16_s4 (gfc_array_i16 * const restrict retarray,
        gfc_array_s4 * const restrict array, GFC_LOGICAL_4 back, 
gfc_charlen_type len);
 export_proto(maxloc0_16_s4);
 
 void
-maxloc0_16_s4 (gfc_array_i16 * const restrict retarray, 
+maxloc0_16_s4 (gfc_array_i16 * const restrict retarray,
        gfc_array_s4 * const restrict array, GFC_LOGICAL_4 back, 
gfc_charlen_type len)
 {
   index_type count[GFC_MAX_DIMENSIONS];
@@ -151,13 +151,13 @@ maxloc0_16_s4 (gfc_array_i16 * const restrict retarray,
 }
 
 
-extern void mmaxloc0_16_s4 (gfc_array_i16 * const restrict, 
+extern void mmaxloc0_16_s4 (gfc_array_i16 * const restrict,
        gfc_array_s4 * const restrict, gfc_array_l1 * const restrict , 
GFC_LOGICAL_4 back,
        gfc_charlen_type len);
 export_proto(mmaxloc0_16_s4);
 
 void
-mmaxloc0_16_s4 (gfc_array_i16 * const restrict retarray, 
+mmaxloc0_16_s4 (gfc_array_i16 * const restrict retarray,
        gfc_array_s4 * const restrict array,
        gfc_array_l1 * const restrict mask, GFC_LOGICAL_4 back,
        gfc_charlen_type len)
@@ -176,7 +176,7 @@ mmaxloc0_16_s4 (gfc_array_i16 * const restrict retarray,
 
   if (mask == NULL)
     {
-#ifdef HAVE_BACK_ARG    
+#ifdef HAVE_BACK_ARG
       maxloc0_16_s4 (retarray, array, back, len);
 #else
       maxloc0_16_s4 (retarray, array, len);
@@ -298,13 +298,13 @@ mmaxloc0_16_s4 (gfc_array_i16 * const restrict retarray,
 }
 
 
-extern void smaxloc0_16_s4 (gfc_array_i16 * const restrict, 
+extern void smaxloc0_16_s4 (gfc_array_i16 * const restrict,
        gfc_array_s4 * const restrict, GFC_LOGICAL_4 *, GFC_LOGICAL_4 back,
        gfc_charlen_type len);
 export_proto(smaxloc0_16_s4);
 
 void
-smaxloc0_16_s4 (gfc_array_i16 * const restrict retarray, 
+smaxloc0_16_s4 (gfc_array_i16 * const restrict retarray,
        gfc_array_s4 * const restrict array,
        GFC_LOGICAL_4 * mask, GFC_LOGICAL_4 back,
        gfc_charlen_type len)
@@ -316,7 +316,7 @@ smaxloc0_16_s4 (gfc_array_i16 * const restrict retarray,
 
   if (mask == NULL || *mask)
     {
-#ifdef HAVE_BACK_ARG    
+#ifdef HAVE_BACK_ARG
       maxloc0_16_s4 (retarray, array, back, len);
 #else
       maxloc0_16_s4 (retarray, array, len);
diff --git a/libgfortran/generated/maxloc0_4_s1.c 
b/libgfortran/generated/maxloc0_4_s1.c
index a14058d17352..e47288992df4 100644
--- a/libgfortran/generated/maxloc0_4_s1.c
+++ b/libgfortran/generated/maxloc0_4_s1.c
@@ -44,12 +44,12 @@ compare_fcn (const GFC_UINTEGER_1 *a, const GFC_UINTEGER_1 
*b, gfc_charlen_type
 
 }
 
-extern void maxloc0_4_s1 (gfc_array_i4 * const restrict retarray, 
+extern void maxloc0_4_s1 (gfc_array_i4 * const restrict retarray,
        gfc_array_s1 * const restrict array, GFC_LOGICAL_4 back, 
gfc_charlen_type len);
 export_proto(maxloc0_4_s1);
 
 void
-maxloc0_4_s1 (gfc_array_i4 * const restrict retarray, 
+maxloc0_4_s1 (gfc_array_i4 * const restrict retarray,
        gfc_array_s1 * const restrict array, GFC_LOGICAL_4 back, 
gfc_charlen_type len)
 {
   index_type count[GFC_MAX_DIMENSIONS];
@@ -151,13 +151,13 @@ maxloc0_4_s1 (gfc_array_i4 * const restrict retarray,
 }
 
 
-extern void mmaxloc0_4_s1 (gfc_array_i4 * const restrict, 
+extern void mmaxloc0_4_s1 (gfc_array_i4 * const restrict,
        gfc_array_s1 * const restrict, gfc_array_l1 * const restrict , 
GFC_LOGICAL_4 back,
        gfc_charlen_type len);
 export_proto(mmaxloc0_4_s1);
 
 void
-mmaxloc0_4_s1 (gfc_array_i4 * const restrict retarray, 
+mmaxloc0_4_s1 (gfc_array_i4 * const restrict retarray,
        gfc_array_s1 * const restrict array,
        gfc_array_l1 * const restrict mask, GFC_LOGICAL_4 back,
        gfc_charlen_type len)
@@ -176,7 +176,7 @@ mmaxloc0_4_s1 (gfc_array_i4 * const restrict retarray,
 
   if (mask == NULL)
     {
-#ifdef HAVE_BACK_ARG    
+#ifdef HAVE_BACK_ARG
       maxloc0_4_s1 (retarray, array, back, len);
 #else
       maxloc0_4_s1 (retarray, array, len);
@@ -298,13 +298,13 @@ mmaxloc0_4_s1 (gfc_array_i4 * const restrict retarray,
 }
 
 
-extern void smaxloc0_4_s1 (gfc_array_i4 * const restrict, 
+extern void smaxloc0_4_s1 (gfc_array_i4 * const restrict,
        gfc_array_s1 * const restrict, GFC_LOGICAL_4 *, GFC_LOGICAL_4 back,
        gfc_charlen_type len);
 export_proto(smaxloc0_4_s1);
 
 void
-smaxloc0_4_s1 (gfc_array_i4 * const restrict retarray, 
+smaxloc0_4_s1 (gfc_array_i4 * const restrict retarray,
        gfc_array_s1 * const restrict array,
        GFC_LOGICAL_4 * mask, GFC_LOGICAL_4 back,
        gfc_charlen_type len)
@@ -316,7 +316,7 @@ smaxloc0_4_s1 (gfc_array_i4 * const restrict retarray,
 
   if (mask == NULL || *mask)
     {
-#ifdef HAVE_BACK_ARG    
+#ifdef HAVE_BACK_ARG
       maxloc0_4_s1 (retarray, array, back, len);
 #else
       maxloc0_4_s1 (retarray, array, len);
diff --git a/libgfortran/generated/maxloc0_4_s4.c 
b/libgfortran/generated/maxloc0_4_s4.c
index 6c2e2d3339d6..cbdf29901ecb 100644
--- a/libgfortran/generated/maxloc0_4_s4.c
+++ b/libgfortran/generated/maxloc0_4_s4.c
@@ -44,12 +44,12 @@ compare_fcn (const GFC_UINTEGER_4 *a, const GFC_UINTEGER_4 
*b, gfc_charlen_type
 
 }
 
-extern void maxloc0_4_s4 (gfc_array_i4 * const restrict retarray, 
+extern void maxloc0_4_s4 (gfc_array_i4 * const restrict retarray,
        gfc_array_s4 * const restrict array, GFC_LOGICAL_4 back, 
gfc_charlen_type len);
 export_proto(maxloc0_4_s4);
 
 void
-maxloc0_4_s4 (gfc_array_i4 * const restrict retarray, 
+maxloc0_4_s4 (gfc_array_i4 * const restrict retarray,
        gfc_array_s4 * const restrict array, GFC_LOGICAL_4 back, 
gfc_charlen_type len)
 {
   index_type count[GFC_MAX_DIMENSIONS];
@@ -151,13 +151,13 @@ maxloc0_4_s4 (gfc_array_i4 * const restrict retarray,
 }
 
 
-extern void mmaxloc0_4_s4 (gfc_array_i4 * const restrict, 
+extern void mmaxloc0_4_s4 (gfc_array_i4 * const restrict,
        gfc_array_s4 * const restrict, gfc_array_l1 * const restrict , 
GFC_LOGICAL_4 back,
        gfc_charlen_type len);
 export_proto(mmaxloc0_4_s4);
 
 void
-mmaxloc0_4_s4 (gfc_array_i4 * const restrict retarray, 
+mmaxloc0_4_s4 (gfc_array_i4 * const restrict retarray,
        gfc_array_s4 * const restrict array,
        gfc_array_l1 * const restrict mask, GFC_LOGICAL_4 back,
        gfc_charlen_type len)
@@ -176,7 +176,7 @@ mmaxloc0_4_s4 (gfc_array_i4 * const restrict retarray,
 
   if (mask == NULL)
     {
-#ifdef HAVE_BACK_ARG    
+#ifdef HAVE_BACK_ARG
       maxloc0_4_s4 (retarray, array, back, len);
 #else
       maxloc0_4_s4 (retarray, array, len);
@@ -298,13 +298,13 @@ mmaxloc0_4_s4 (gfc_array_i4 * const restrict retarray,
 }
 
 
-extern void smaxloc0_4_s4 (gfc_array_i4 * const restrict, 
+extern void smaxloc0_4_s4 (gfc_array_i4 * const restrict,
        gfc_array_s4 * const restrict, GFC_LOGICAL_4 *, GFC_LOGICAL_4 back,
        gfc_charlen_type len);
 export_proto(smaxloc0_4_s4);
 
 void
-smaxloc0_4_s4 (gfc_array_i4 * const restrict retarray, 
+smaxloc0_4_s4 (gfc_array_i4 * const restrict retarray,
        gfc_array_s4 * const restrict array,
        GFC_LOGICAL_4 * mask, GFC_LOGICAL_4 back,
        gfc_charlen_type len)
@@ -316,7 +316,7 @@ smaxloc0_4_s4 (gfc_array_i4 * const restrict retarray,
 
   if (mask == NULL || *mask)
     {
-#ifdef HAVE_BACK_ARG    
+#ifdef HAVE_BACK_ARG
       maxloc0_4_s4 (retarray, array, back, len);
 #else
       maxloc0_4_s4 (retarray, array, len);
diff --git a/libgfortran/generated/maxloc0_8_s1.c 
b/libgfortran/generated/maxloc0_8_s1.c
index 85cfa97e3d8f..c819b1ee4724 100644
--- a/libgfortran/generated/maxloc0_8_s1.c
+++ b/libgfortran/generated/maxloc0_8_s1.c
@@ -44,12 +44,12 @@ compare_fcn (const GFC_UINTEGER_1 *a, const GFC_UINTEGER_1 
*b, gfc_charlen_type
 
 }
 
-extern void maxloc0_8_s1 (gfc_array_i8 * const restrict retarray, 
+extern void maxloc0_8_s1 (gfc_array_i8 * const restrict retarray,
        gfc_array_s1 * const restrict array, GFC_LOGICAL_4 back, 
gfc_charlen_type len);
 export_proto(maxloc0_8_s1);
 
 void
-maxloc0_8_s1 (gfc_array_i8 * const restrict retarray, 
+maxloc0_8_s1 (gfc_array_i8 * const restrict retarray,
        gfc_array_s1 * const restrict array, GFC_LOGICAL_4 back, 
gfc_charlen_type len)
 {
   index_type count[GFC_MAX_DIMENSIONS];
@@ -151,13 +151,13 @@ maxloc0_8_s1 (gfc_array_i8 * const restrict retarray,
 }
 
 
-extern void mmaxloc0_8_s1 (gfc_array_i8 * const restrict, 
+extern void mmaxloc0_8_s1 (gfc_array_i8 * const restrict,
        gfc_array_s1 * const restrict, gfc_array_l1 * const restrict , 
GFC_LOGICAL_4 back,
        gfc_charlen_type len);
 export_proto(mmaxloc0_8_s1);
 
 void
-mmaxloc0_8_s1 (gfc_array_i8 * const restrict retarray, 
+mmaxloc0_8_s1 (gfc_array_i8 * const restrict retarray,
        gfc_array_s1 * const restrict array,
        gfc_array_l1 * const restrict mask, GFC_LOGICAL_4 back,
        gfc_charlen_type len)
@@ -176,7 +176,7 @@ mmaxloc0_8_s1 (gfc_array_i8 * const restrict retarray,
 
   if (mask == NULL)
     {
-#ifdef HAVE_BACK_ARG    
+#ifdef HAVE_BACK_ARG
       maxloc0_8_s1 (retarray, array, back, len);
 #else
       maxloc0_8_s1 (retarray, array, len);
@@ -298,13 +298,13 @@ mmaxloc0_8_s1 (gfc_array_i8 * const restrict retarray,
 }
 
 
-extern void smaxloc0_8_s1 (gfc_array_i8 * const restrict, 
+extern void smaxloc0_8_s1 (gfc_array_i8 * const restrict,
        gfc_array_s1 * const restrict, GFC_LOGICAL_4 *, GFC_LOGICAL_4 back,
        gfc_charlen_type len);
 export_proto(smaxloc0_8_s1);
 
 void
-smaxloc0_8_s1 (gfc_array_i8 * const restrict retarray, 
+smaxloc0_8_s1 (gfc_array_i8 * const restrict retarray,
        gfc_array_s1 * const restrict array,
        GFC_LOGICAL_4 * mask, GFC_LOGICAL_4 back,
        gfc_charlen_type len)
@@ -316,7 +316,7 @@ smaxloc0_8_s1 (gfc_array_i8 * const restrict retarray,
 
   if (mask == NULL || *mask)
     {
-#ifdef HAVE_BACK_ARG    
+#ifdef HAVE_BACK_ARG
       maxloc0_8_s1 (retarray, array, back, len);
 #else
       maxloc0_8_s1 (retarray, array, len);
diff --git a/libgfortran/generated/maxloc0_8_s4.c 
b/libgfortran/generated/maxloc0_8_s4.c
index 6634d7a9a4bb..f390bb64e44b 100644
--- a/libgfortran/generated/maxloc0_8_s4.c
+++ b/libgfortran/generated/maxloc0_8_s4.c
@@ -44,12 +44,12 @@ compare_fcn (const GFC_UINTEGER_4 *a, const GFC_UINTEGER_4 
*b, gfc_charlen_type
 
 }
 
-extern void maxloc0_8_s4 (gfc_array_i8 * const restrict retarray, 
+extern void maxloc0_8_s4 (gfc_array_i8 * const restrict retarray,
        gfc_array_s4 * const restrict array, GFC_LOGICAL_4 back, 
gfc_charlen_type len);
 export_proto(maxloc0_8_s4);
 
 void
-maxloc0_8_s4 (gfc_array_i8 * const restrict retarray, 
+maxloc0_8_s4 (gfc_array_i8 * const restrict retarray,
        gfc_array_s4 * const restrict array, GFC_LOGICAL_4 back, 
gfc_charlen_type len)
 {
   index_type count[GFC_MAX_DIMENSIONS];
@@ -151,13 +151,13 @@ maxloc0_8_s4 (gfc_array_i8 * const restrict retarray,
 }
 
 
-extern void mmaxloc0_8_s4 (gfc_array_i8 * const restrict, 
+extern void mmaxloc0_8_s4 (gfc_array_i8 * const restrict,
        gfc_array_s4 * const restrict, gfc_array_l1 * const restrict , 
GFC_LOGICAL_4 back,
        gfc_charlen_type len);
 export_proto(mmaxloc0_8_s4);
 
 void
-mmaxloc0_8_s4 (gfc_array_i8 * const restrict retarray, 
+mmaxloc0_8_s4 (gfc_array_i8 * const restrict retarray,
        gfc_array_s4 * const restrict array,
        gfc_array_l1 * const restrict mask, GFC_LOGICAL_4 back,
        gfc_charlen_type len)
@@ -176,7 +176,7 @@ mmaxloc0_8_s4 (gfc_array_i8 * const restrict retarray,
 
   if (mask == NULL)
     {
-#ifdef HAVE_BACK_ARG    
+#ifdef HAVE_BACK_ARG
       maxloc0_8_s4 (retarray, array, back, len);
 #else
       maxloc0_8_s4 (retarray, array, len);
@@ -298,13 +298,13 @@ mmaxloc0_8_s4 (gfc_array_i8 * const restrict retarray,
 }
 
 
-extern void smaxloc0_8_s4 (gfc_array_i8 * const restrict, 
+extern void smaxloc0_8_s4 (gfc_array_i8 * const restrict,
        gfc_array_s4 * const restrict, GFC_LOGICAL_4 *, GFC_LOGICAL_4 back,
        gfc_charlen_type len);
 export_proto(smaxloc0_8_s4);
 
 void
-smaxloc0_8_s4 (gfc_array_i8 * const restrict retarray, 
+smaxloc0_8_s4 (gfc_array_i8 * const restrict retarray,
        gfc_array_s4 * const restrict array,
        GFC_LOGICAL_4 * mask, GFC_LOGICAL_4 back,
        gfc_charlen_type len)
@@ -316,7 +316,7 @@ smaxloc0_8_s4 (gfc_array_i8 * const restrict retarray,
 
   if (mask == NULL || *mask)
     {
-#ifdef HAVE_BACK_ARG    
+#ifdef HAVE_BACK_ARG
       maxloc0_8_s4 (retarray, array, back, len);
 #else
       maxloc0_8_s4 (retarray, array, len);
diff --git a/libgfortran/generated/maxval1_s1.c 
b/libgfortran/generated/maxval1_s1.c
index aee4b0f8ab4e..e4c487e3cb77 100644
--- a/libgfortran/generated/maxval1_s1.c
+++ b/libgfortran/generated/maxval1_s1.c
@@ -117,7 +117,7 @@ maxval1_s1 (gfc_array_s1 * const restrict retarray,
 
       alloc_size = GFC_DESCRIPTOR_SPACING(retarray,rank-1) * extent[rank-1];
 
-      retarray->base_addr = xmallocarray (alloc_size, sizeof (GFC_UINTEGER_1));
+      retarray->base_addr = xmalloc (alloc_size);
       if (alloc_size == 0)
        return;
     }
@@ -158,13 +158,14 @@ maxval1_s1 (gfc_array_s1 * const restrict retarray,
          memset (dest, 0, sizeof (*dest) * string_len);
        else
          {
-           for (n = 0; n < len; n++, src += delta)
+           for (n = 0; n < len; n++)
              {
 
                if (compare_fcn (src, retval, string_len) > 0)
                  {
                    retval = src;
                  }
+               src = (GFC_UINTEGER_1*) (((char*)src) + delta);
              }
            
            memcpy (dest, retval, sizeof (*dest) * string_len);
@@ -309,7 +310,7 @@ mmaxval1_s1 (gfc_array_s1 * const restrict retarray,
       retarray->offset = 0;
       retarray->dtype.rank = rank;
 
-      retarray->base_addr = xmallocarray (alloc_size, sizeof (GFC_UINTEGER_1));
+      retarray->base_addr = xmalloc (alloc_size);
       if (alloc_size == 0)
        return;
     }
@@ -350,7 +351,7 @@ mmaxval1_s1 (gfc_array_s1 * const restrict retarray,
        const GFC_UINTEGER_1 *retval;
        memset (dest, 0, sizeof (*dest) * string_len);
        retval = dest;
-       for (n = 0; n < len; n++, src += delta, msrc += mdelta)
+       for (n = 0; n < len; n++)
          {
 
                if (*msrc)
@@ -366,6 +367,8 @@ mmaxval1_s1 (gfc_array_s1 * const restrict retarray,
                    retval = src;
                  }
              
+           src = (GFC_UINTEGER_1*) (((char*)src) + delta);
+           msrc += mdelta;
          }
        memcpy (dest, retval, sizeof (*dest) * string_len);
       }
@@ -479,7 +482,7 @@ smaxval1_s1 (gfc_array_s1 * const restrict retarray,
 
       alloc_size = GFC_DESCRIPTOR_SPACING(retarray,rank-1) * extent[rank-1];
 
-      retarray->base_addr = xmallocarray (alloc_size, sizeof (GFC_UINTEGER_1));
+      retarray->base_addr = xmalloc (alloc_size);
       if (alloc_size == 0)
        return;
     }
diff --git a/libgfortran/generated/maxval1_s4.c 
b/libgfortran/generated/maxval1_s4.c
index 08a04306a723..686e18276a12 100644
--- a/libgfortran/generated/maxval1_s4.c
+++ b/libgfortran/generated/maxval1_s4.c
@@ -117,7 +117,7 @@ maxval1_s4 (gfc_array_s4 * const restrict retarray,
 
       alloc_size = GFC_DESCRIPTOR_SPACING(retarray,rank-1) * extent[rank-1];
 
-      retarray->base_addr = xmallocarray (alloc_size, sizeof (GFC_UINTEGER_4));
+      retarray->base_addr = xmalloc (alloc_size);
       if (alloc_size == 0)
        return;
     }
@@ -158,13 +158,14 @@ maxval1_s4 (gfc_array_s4 * const restrict retarray,
          memset (dest, 0, sizeof (*dest) * string_len);
        else
          {
-           for (n = 0; n < len; n++, src += delta)
+           for (n = 0; n < len; n++)
              {
 
                if (compare_fcn (src, retval, string_len) > 0)
                  {
                    retval = src;
                  }
+               src = (GFC_UINTEGER_4*) (((char*)src) + delta);
              }
            
            memcpy (dest, retval, sizeof (*dest) * string_len);
@@ -309,7 +310,7 @@ mmaxval1_s4 (gfc_array_s4 * const restrict retarray,
       retarray->offset = 0;
       retarray->dtype.rank = rank;
 
-      retarray->base_addr = xmallocarray (alloc_size, sizeof (GFC_UINTEGER_4));
+      retarray->base_addr = xmalloc (alloc_size);
       if (alloc_size == 0)
        return;
     }
@@ -350,7 +351,7 @@ mmaxval1_s4 (gfc_array_s4 * const restrict retarray,
        const GFC_UINTEGER_4 *retval;
        memset (dest, 0, sizeof (*dest) * string_len);
        retval = dest;
-       for (n = 0; n < len; n++, src += delta, msrc += mdelta)
+       for (n = 0; n < len; n++)
          {
 
                if (*msrc)
@@ -366,6 +367,8 @@ mmaxval1_s4 (gfc_array_s4 * const restrict retarray,
                    retval = src;
                  }
              
+           src = (GFC_UINTEGER_4*) (((char*)src) + delta);
+           msrc += mdelta;
          }
        memcpy (dest, retval, sizeof (*dest) * string_len);
       }
@@ -479,7 +482,7 @@ smaxval1_s4 (gfc_array_s4 * const restrict retarray,
 
       alloc_size = GFC_DESCRIPTOR_SPACING(retarray,rank-1) * extent[rank-1];
 
-      retarray->base_addr = xmallocarray (alloc_size, sizeof (GFC_UINTEGER_4));
+      retarray->base_addr = xmalloc (alloc_size);
       if (alloc_size == 0)
        return;
     }
diff --git a/libgfortran/generated/minloc0_16_s1.c 
b/libgfortran/generated/minloc0_16_s1.c
index c5f600de2f82..58b3cea87d98 100644
--- a/libgfortran/generated/minloc0_16_s1.c
+++ b/libgfortran/generated/minloc0_16_s1.c
@@ -44,12 +44,12 @@ compare_fcn (const GFC_UINTEGER_1 *a, const GFC_UINTEGER_1 
*b, gfc_charlen_type
 
 }
 
-extern void minloc0_16_s1 (gfc_array_i16 * const restrict retarray, 
+extern void minloc0_16_s1 (gfc_array_i16 * const restrict retarray,
        gfc_array_s1 * const restrict array, GFC_LOGICAL_4 back, 
gfc_charlen_type len);
 export_proto(minloc0_16_s1);
 
 void
-minloc0_16_s1 (gfc_array_i16 * const restrict retarray, 
+minloc0_16_s1 (gfc_array_i16 * const restrict retarray,
        gfc_array_s1 * const restrict array, GFC_LOGICAL_4 back, 
gfc_charlen_type len)
 {
   index_type count[GFC_MAX_DIMENSIONS];
@@ -151,13 +151,13 @@ minloc0_16_s1 (gfc_array_i16 * const restrict retarray,
 }
 
 
-extern void mminloc0_16_s1 (gfc_array_i16 * const restrict, 
+extern void mminloc0_16_s1 (gfc_array_i16 * const restrict,
        gfc_array_s1 * const restrict, gfc_array_l1 * const restrict , 
GFC_LOGICAL_4 back,
        gfc_charlen_type len);
 export_proto(mminloc0_16_s1);
 
 void
-mminloc0_16_s1 (gfc_array_i16 * const restrict retarray, 
+mminloc0_16_s1 (gfc_array_i16 * const restrict retarray,
        gfc_array_s1 * const restrict array,
        gfc_array_l1 * const restrict mask, GFC_LOGICAL_4 back,
        gfc_charlen_type len)
@@ -176,7 +176,7 @@ mminloc0_16_s1 (gfc_array_i16 * const restrict retarray,
 
   if (mask == NULL)
     {
-#ifdef HAVE_BACK_ARG    
+#ifdef HAVE_BACK_ARG
       minloc0_16_s1 (retarray, array, back, len);
 #else
       minloc0_16_s1 (retarray, array, len);
@@ -298,13 +298,13 @@ mminloc0_16_s1 (gfc_array_i16 * const restrict retarray,
 }
 
 
-extern void sminloc0_16_s1 (gfc_array_i16 * const restrict, 
+extern void sminloc0_16_s1 (gfc_array_i16 * const restrict,
        gfc_array_s1 * const restrict, GFC_LOGICAL_4 *, GFC_LOGICAL_4 back,
        gfc_charlen_type len);
 export_proto(sminloc0_16_s1);
 
 void
-sminloc0_16_s1 (gfc_array_i16 * const restrict retarray, 
+sminloc0_16_s1 (gfc_array_i16 * const restrict retarray,
        gfc_array_s1 * const restrict array,
        GFC_LOGICAL_4 * mask, GFC_LOGICAL_4 back,
        gfc_charlen_type len)
@@ -316,7 +316,7 @@ sminloc0_16_s1 (gfc_array_i16 * const restrict retarray,
 
   if (mask == NULL || *mask)
     {
-#ifdef HAVE_BACK_ARG    
+#ifdef HAVE_BACK_ARG
       minloc0_16_s1 (retarray, array, back, len);
 #else
       minloc0_16_s1 (retarray, array, len);
diff --git a/libgfortran/generated/minloc0_16_s4.c 
b/libgfortran/generated/minloc0_16_s4.c
index bd1c5f551ef8..e00d308bb4e7 100644
--- a/libgfortran/generated/minloc0_16_s4.c
+++ b/libgfortran/generated/minloc0_16_s4.c
@@ -44,12 +44,12 @@ compare_fcn (const GFC_UINTEGER_4 *a, const GFC_UINTEGER_4 
*b, gfc_charlen_type
 
 }
 
-extern void minloc0_16_s4 (gfc_array_i16 * const restrict retarray, 
+extern void minloc0_16_s4 (gfc_array_i16 * const restrict retarray,
        gfc_array_s4 * const restrict array, GFC_LOGICAL_4 back, 
gfc_charlen_type len);
 export_proto(minloc0_16_s4);
 
 void
-minloc0_16_s4 (gfc_array_i16 * const restrict retarray, 
+minloc0_16_s4 (gfc_array_i16 * const restrict retarray,
        gfc_array_s4 * const restrict array, GFC_LOGICAL_4 back, 
gfc_charlen_type len)
 {
   index_type count[GFC_MAX_DIMENSIONS];
@@ -151,13 +151,13 @@ minloc0_16_s4 (gfc_array_i16 * const restrict retarray,
 }
 
 
-extern void mminloc0_16_s4 (gfc_array_i16 * const restrict, 
+extern void mminloc0_16_s4 (gfc_array_i16 * const restrict,
        gfc_array_s4 * const restrict, gfc_array_l1 * const restrict , 
GFC_LOGICAL_4 back,
        gfc_charlen_type len);
 export_proto(mminloc0_16_s4);
 
 void
-mminloc0_16_s4 (gfc_array_i16 * const restrict retarray, 
+mminloc0_16_s4 (gfc_array_i16 * const restrict retarray,
        gfc_array_s4 * const restrict array,
        gfc_array_l1 * const restrict mask, GFC_LOGICAL_4 back,
        gfc_charlen_type len)
@@ -176,7 +176,7 @@ mminloc0_16_s4 (gfc_array_i16 * const restrict retarray,
 
   if (mask == NULL)
     {
-#ifdef HAVE_BACK_ARG    
+#ifdef HAVE_BACK_ARG
       minloc0_16_s4 (retarray, array, back, len);
 #else
       minloc0_16_s4 (retarray, array, len);
@@ -298,13 +298,13 @@ mminloc0_16_s4 (gfc_array_i16 * const restrict retarray,
 }
 
 
-extern void sminloc0_16_s4 (gfc_array_i16 * const restrict, 
+extern void sminloc0_16_s4 (gfc_array_i16 * const restrict,
        gfc_array_s4 * const restrict, GFC_LOGICAL_4 *, GFC_LOGICAL_4 back,
        gfc_charlen_type len);
 export_proto(sminloc0_16_s4);
 
 void
-sminloc0_16_s4 (gfc_array_i16 * const restrict retarray, 
+sminloc0_16_s4 (gfc_array_i16 * const restrict retarray,
        gfc_array_s4 * const restrict array,
        GFC_LOGICAL_4 * mask, GFC_LOGICAL_4 back,
        gfc_charlen_type len)
@@ -316,7 +316,7 @@ sminloc0_16_s4 (gfc_array_i16 * const restrict retarray,
 
   if (mask == NULL || *mask)
     {
-#ifdef HAVE_BACK_ARG    
+#ifdef HAVE_BACK_ARG
       minloc0_16_s4 (retarray, array, back, len);
 #else
       minloc0_16_s4 (retarray, array, len);
diff --git a/libgfortran/generated/minloc0_4_s1.c 
b/libgfortran/generated/minloc0_4_s1.c
index 001693a99eeb..6bd39fe20adf 100644
--- a/libgfortran/generated/minloc0_4_s1.c
+++ b/libgfortran/generated/minloc0_4_s1.c
@@ -44,12 +44,12 @@ compare_fcn (const GFC_UINTEGER_1 *a, const GFC_UINTEGER_1 
*b, gfc_charlen_type
 
 }
 
-extern void minloc0_4_s1 (gfc_array_i4 * const restrict retarray, 
+extern void minloc0_4_s1 (gfc_array_i4 * const restrict retarray,
        gfc_array_s1 * const restrict array, GFC_LOGICAL_4 back, 
gfc_charlen_type len);
 export_proto(minloc0_4_s1);
 
 void
-minloc0_4_s1 (gfc_array_i4 * const restrict retarray, 
+minloc0_4_s1 (gfc_array_i4 * const restrict retarray,
        gfc_array_s1 * const restrict array, GFC_LOGICAL_4 back, 
gfc_charlen_type len)
 {
   index_type count[GFC_MAX_DIMENSIONS];
@@ -151,13 +151,13 @@ minloc0_4_s1 (gfc_array_i4 * const restrict retarray,
 }
 
 
-extern void mminloc0_4_s1 (gfc_array_i4 * const restrict, 
+extern void mminloc0_4_s1 (gfc_array_i4 * const restrict,
        gfc_array_s1 * const restrict, gfc_array_l1 * const restrict , 
GFC_LOGICAL_4 back,
        gfc_charlen_type len);
 export_proto(mminloc0_4_s1);
 
 void
-mminloc0_4_s1 (gfc_array_i4 * const restrict retarray, 
+mminloc0_4_s1 (gfc_array_i4 * const restrict retarray,
        gfc_array_s1 * const restrict array,
        gfc_array_l1 * const restrict mask, GFC_LOGICAL_4 back,
        gfc_charlen_type len)
@@ -176,7 +176,7 @@ mminloc0_4_s1 (gfc_array_i4 * const restrict retarray,
 
   if (mask == NULL)
     {
-#ifdef HAVE_BACK_ARG    
+#ifdef HAVE_BACK_ARG
       minloc0_4_s1 (retarray, array, back, len);
 #else
       minloc0_4_s1 (retarray, array, len);
@@ -298,13 +298,13 @@ mminloc0_4_s1 (gfc_array_i4 * const restrict retarray,
 }
 
 
-extern void sminloc0_4_s1 (gfc_array_i4 * const restrict, 
+extern void sminloc0_4_s1 (gfc_array_i4 * const restrict,
        gfc_array_s1 * const restrict, GFC_LOGICAL_4 *, GFC_LOGICAL_4 back,
        gfc_charlen_type len);
 export_proto(sminloc0_4_s1);
 
 void
-sminloc0_4_s1 (gfc_array_i4 * const restrict retarray, 
+sminloc0_4_s1 (gfc_array_i4 * const restrict retarray,
        gfc_array_s1 * const restrict array,
        GFC_LOGICAL_4 * mask, GFC_LOGICAL_4 back,
        gfc_charlen_type len)
@@ -316,7 +316,7 @@ sminloc0_4_s1 (gfc_array_i4 * const restrict retarray,
 
   if (mask == NULL || *mask)
     {
-#ifdef HAVE_BACK_ARG    
+#ifdef HAVE_BACK_ARG
       minloc0_4_s1 (retarray, array, back, len);
 #else
       minloc0_4_s1 (retarray, array, len);
diff --git a/libgfortran/generated/minloc0_4_s4.c 
b/libgfortran/generated/minloc0_4_s4.c
index ad06948320a2..f38063ddc814 100644
--- a/libgfortran/generated/minloc0_4_s4.c
+++ b/libgfortran/generated/minloc0_4_s4.c
@@ -44,12 +44,12 @@ compare_fcn (const GFC_UINTEGER_4 *a, const GFC_UINTEGER_4 
*b, gfc_charlen_type
 
 }
 
-extern void minloc0_4_s4 (gfc_array_i4 * const restrict retarray, 
+extern void minloc0_4_s4 (gfc_array_i4 * const restrict retarray,
        gfc_array_s4 * const restrict array, GFC_LOGICAL_4 back, 
gfc_charlen_type len);
 export_proto(minloc0_4_s4);
 
 void
-minloc0_4_s4 (gfc_array_i4 * const restrict retarray, 
+minloc0_4_s4 (gfc_array_i4 * const restrict retarray,
        gfc_array_s4 * const restrict array, GFC_LOGICAL_4 back, 
gfc_charlen_type len)
 {
   index_type count[GFC_MAX_DIMENSIONS];
@@ -151,13 +151,13 @@ minloc0_4_s4 (gfc_array_i4 * const restrict retarray,
 }
 
 
-extern void mminloc0_4_s4 (gfc_array_i4 * const restrict, 
+extern void mminloc0_4_s4 (gfc_array_i4 * const restrict,
        gfc_array_s4 * const restrict, gfc_array_l1 * const restrict , 
GFC_LOGICAL_4 back,
        gfc_charlen_type len);
 export_proto(mminloc0_4_s4);
 
 void
-mminloc0_4_s4 (gfc_array_i4 * const restrict retarray, 
+mminloc0_4_s4 (gfc_array_i4 * const restrict retarray,
        gfc_array_s4 * const restrict array,
        gfc_array_l1 * const restrict mask, GFC_LOGICAL_4 back,
        gfc_charlen_type len)
@@ -176,7 +176,7 @@ mminloc0_4_s4 (gfc_array_i4 * const restrict retarray,
 
   if (mask == NULL)
     {
-#ifdef HAVE_BACK_ARG    
+#ifdef HAVE_BACK_ARG
       minloc0_4_s4 (retarray, array, back, len);
 #else
       minloc0_4_s4 (retarray, array, len);
@@ -298,13 +298,13 @@ mminloc0_4_s4 (gfc_array_i4 * const restrict retarray,
 }
 
 
-extern void sminloc0_4_s4 (gfc_array_i4 * const restrict, 
+extern void sminloc0_4_s4 (gfc_array_i4 * const restrict,
        gfc_array_s4 * const restrict, GFC_LOGICAL_4 *, GFC_LOGICAL_4 back,
        gfc_charlen_type len);
 export_proto(sminloc0_4_s4);
 
 void
-sminloc0_4_s4 (gfc_array_i4 * const restrict retarray, 
+sminloc0_4_s4 (gfc_array_i4 * const restrict retarray,
        gfc_array_s4 * const restrict array,
        GFC_LOGICAL_4 * mask, GFC_LOGICAL_4 back,
        gfc_charlen_type len)
@@ -316,7 +316,7 @@ sminloc0_4_s4 (gfc_array_i4 * const restrict retarray,
 
   if (mask == NULL || *mask)
     {
-#ifdef HAVE_BACK_ARG    
+#ifdef HAVE_BACK_ARG
       minloc0_4_s4 (retarray, array, back, len);
 #else
       minloc0_4_s4 (retarray, array, len);
diff --git a/libgfortran/generated/minloc0_8_s1.c 
b/libgfortran/generated/minloc0_8_s1.c
index 95929c742ee2..f4231273501a 100644
--- a/libgfortran/generated/minloc0_8_s1.c
+++ b/libgfortran/generated/minloc0_8_s1.c
@@ -44,12 +44,12 @@ compare_fcn (const GFC_UINTEGER_1 *a, const GFC_UINTEGER_1 
*b, gfc_charlen_type
 
 }
 
-extern void minloc0_8_s1 (gfc_array_i8 * const restrict retarray, 
+extern void minloc0_8_s1 (gfc_array_i8 * const restrict retarray,
        gfc_array_s1 * const restrict array, GFC_LOGICAL_4 back, 
gfc_charlen_type len);
 export_proto(minloc0_8_s1);
 
 void
-minloc0_8_s1 (gfc_array_i8 * const restrict retarray, 
+minloc0_8_s1 (gfc_array_i8 * const restrict retarray,
        gfc_array_s1 * const restrict array, GFC_LOGICAL_4 back, 
gfc_charlen_type len)
 {
   index_type count[GFC_MAX_DIMENSIONS];
@@ -151,13 +151,13 @@ minloc0_8_s1 (gfc_array_i8 * const restrict retarray,
 }
 
 
-extern void mminloc0_8_s1 (gfc_array_i8 * const restrict, 
+extern void mminloc0_8_s1 (gfc_array_i8 * const restrict,
        gfc_array_s1 * const restrict, gfc_array_l1 * const restrict , 
GFC_LOGICAL_4 back,
        gfc_charlen_type len);
 export_proto(mminloc0_8_s1);
 
 void
-mminloc0_8_s1 (gfc_array_i8 * const restrict retarray, 
+mminloc0_8_s1 (gfc_array_i8 * const restrict retarray,
        gfc_array_s1 * const restrict array,
        gfc_array_l1 * const restrict mask, GFC_LOGICAL_4 back,
        gfc_charlen_type len)
@@ -176,7 +176,7 @@ mminloc0_8_s1 (gfc_array_i8 * const restrict retarray,
 
   if (mask == NULL)
     {
-#ifdef HAVE_BACK_ARG    
+#ifdef HAVE_BACK_ARG
       minloc0_8_s1 (retarray, array, back, len);
 #else
       minloc0_8_s1 (retarray, array, len);
@@ -298,13 +298,13 @@ mminloc0_8_s1 (gfc_array_i8 * const restrict retarray,
 }
 
 
-extern void sminloc0_8_s1 (gfc_array_i8 * const restrict, 
+extern void sminloc0_8_s1 (gfc_array_i8 * const restrict,
        gfc_array_s1 * const restrict, GFC_LOGICAL_4 *, GFC_LOGICAL_4 back,
        gfc_charlen_type len);
 export_proto(sminloc0_8_s1);
 
 void
-sminloc0_8_s1 (gfc_array_i8 * const restrict retarray, 
+sminloc0_8_s1 (gfc_array_i8 * const restrict retarray,
        gfc_array_s1 * const restrict array,
        GFC_LOGICAL_4 * mask, GFC_LOGICAL_4 back,
        gfc_charlen_type len)
@@ -316,7 +316,7 @@ sminloc0_8_s1 (gfc_array_i8 * const restrict retarray,
 
   if (mask == NULL || *mask)
     {
-#ifdef HAVE_BACK_ARG    
+#ifdef HAVE_BACK_ARG
       minloc0_8_s1 (retarray, array, back, len);
 #else
       minloc0_8_s1 (retarray, array, len);
diff --git a/libgfortran/generated/minloc0_8_s4.c 
b/libgfortran/generated/minloc0_8_s4.c
index 470025cda31b..42cb0fbc6c51 100644
--- a/libgfortran/generated/minloc0_8_s4.c
+++ b/libgfortran/generated/minloc0_8_s4.c
@@ -44,12 +44,12 @@ compare_fcn (const GFC_UINTEGER_4 *a, const GFC_UINTEGER_4 
*b, gfc_charlen_type
 
 }
 
-extern void minloc0_8_s4 (gfc_array_i8 * const restrict retarray, 
+extern void minloc0_8_s4 (gfc_array_i8 * const restrict retarray,
        gfc_array_s4 * const restrict array, GFC_LOGICAL_4 back, 
gfc_charlen_type len);
 export_proto(minloc0_8_s4);
 
 void
-minloc0_8_s4 (gfc_array_i8 * const restrict retarray, 
+minloc0_8_s4 (gfc_array_i8 * const restrict retarray,
        gfc_array_s4 * const restrict array, GFC_LOGICAL_4 back, 
gfc_charlen_type len)
 {
   index_type count[GFC_MAX_DIMENSIONS];
@@ -151,13 +151,13 @@ minloc0_8_s4 (gfc_array_i8 * const restrict retarray,
 }
 
 
-extern void mminloc0_8_s4 (gfc_array_i8 * const restrict, 
+extern void mminloc0_8_s4 (gfc_array_i8 * const restrict,
        gfc_array_s4 * const restrict, gfc_array_l1 * const restrict , 
GFC_LOGICAL_4 back,
        gfc_charlen_type len);
 export_proto(mminloc0_8_s4);
 
 void
-mminloc0_8_s4 (gfc_array_i8 * const restrict retarray, 
+mminloc0_8_s4 (gfc_array_i8 * const restrict retarray,
        gfc_array_s4 * const restrict array,
        gfc_array_l1 * const restrict mask, GFC_LOGICAL_4 back,
        gfc_charlen_type len)
@@ -176,7 +176,7 @@ mminloc0_8_s4 (gfc_array_i8 * const restrict retarray,
 
   if (mask == NULL)
     {
-#ifdef HAVE_BACK_ARG    
+#ifdef HAVE_BACK_ARG
       minloc0_8_s4 (retarray, array, back, len);
 #else
       minloc0_8_s4 (retarray, array, len);
@@ -298,13 +298,13 @@ mminloc0_8_s4 (gfc_array_i8 * const restrict retarray,
 }
 
 
-extern void sminloc0_8_s4 (gfc_array_i8 * const restrict, 
+extern void sminloc0_8_s4 (gfc_array_i8 * const restrict,
        gfc_array_s4 * const restrict, GFC_LOGICAL_4 *, GFC_LOGICAL_4 back,
        gfc_charlen_type len);
 export_proto(sminloc0_8_s4);
 
 void
-sminloc0_8_s4 (gfc_array_i8 * const restrict retarray, 
+sminloc0_8_s4 (gfc_array_i8 * const restrict retarray,
        gfc_array_s4 * const restrict array,
        GFC_LOGICAL_4 * mask, GFC_LOGICAL_4 back,
        gfc_charlen_type len)
@@ -316,7 +316,7 @@ sminloc0_8_s4 (gfc_array_i8 * const restrict retarray,
 
   if (mask == NULL || *mask)
     {
-#ifdef HAVE_BACK_ARG    
+#ifdef HAVE_BACK_ARG
       minloc0_8_s4 (retarray, array, back, len);
 #else
       minloc0_8_s4 (retarray, array, len);
diff --git a/libgfortran/generated/minval1_s1.c 
b/libgfortran/generated/minval1_s1.c
index b2ac7f33a934..00f4473c3b45 100644
--- a/libgfortran/generated/minval1_s1.c
+++ b/libgfortran/generated/minval1_s1.c
@@ -117,7 +117,7 @@ minval1_s1 (gfc_array_s1 * const restrict retarray,
 
       alloc_size = GFC_DESCRIPTOR_SPACING(retarray,rank-1) * extent[rank-1];
 
-      retarray->base_addr = xmallocarray (alloc_size, sizeof (GFC_UINTEGER_1));
+      retarray->base_addr = xmalloc (alloc_size);
       if (alloc_size == 0)
        return;
     }
@@ -158,13 +158,14 @@ minval1_s1 (gfc_array_s1 * const restrict retarray,
          memset (dest, 255, sizeof (*dest) * string_len);
        else
          {
-           for (n = 0; n < len; n++, src += delta)
+           for (n = 0; n < len; n++)
              {
 
                if (compare_fcn (src, retval, string_len) < 0)
                  {
                    retval = src;
                  }
+               src = (GFC_UINTEGER_1*) (((char*)src) + delta);
              }
            
            memcpy (dest, retval, sizeof (*dest) * string_len);
@@ -309,7 +310,7 @@ mminval1_s1 (gfc_array_s1 * const restrict retarray,
       retarray->offset = 0;
       retarray->dtype.rank = rank;
 
-      retarray->base_addr = xmallocarray (alloc_size, sizeof (GFC_UINTEGER_1));
+      retarray->base_addr = xmalloc (alloc_size);
       if (alloc_size == 0)
        return;
     }
@@ -350,7 +351,7 @@ mminval1_s1 (gfc_array_s1 * const restrict retarray,
        const GFC_UINTEGER_1 *retval;
        memset (dest, 255, sizeof (*dest) * string_len);
        retval = dest;
-       for (n = 0; n < len; n++, src += delta, msrc += mdelta)
+       for (n = 0; n < len; n++)
          {
 
                if (*msrc)
@@ -366,6 +367,8 @@ mminval1_s1 (gfc_array_s1 * const restrict retarray,
                    retval = src;
                  }
              
+           src = (GFC_UINTEGER_1*) (((char*)src) + delta);
+           msrc += mdelta;
          }
        memcpy (dest, retval, sizeof (*dest) * string_len);
       }
@@ -479,7 +482,7 @@ sminval1_s1 (gfc_array_s1 * const restrict retarray,
 
       alloc_size = GFC_DESCRIPTOR_SPACING(retarray,rank-1) * extent[rank-1];
 
-      retarray->base_addr = xmallocarray (alloc_size, sizeof (GFC_UINTEGER_1));
+      retarray->base_addr = xmalloc (alloc_size);
       if (alloc_size == 0)
        return;
     }
diff --git a/libgfortran/generated/minval1_s4.c 
b/libgfortran/generated/minval1_s4.c
index 8adc81c102f4..1ecbc7b75f25 100644
--- a/libgfortran/generated/minval1_s4.c
+++ b/libgfortran/generated/minval1_s4.c
@@ -117,7 +117,7 @@ minval1_s4 (gfc_array_s4 * const restrict retarray,
 
       alloc_size = GFC_DESCRIPTOR_SPACING(retarray,rank-1) * extent[rank-1];
 
-      retarray->base_addr = xmallocarray (alloc_size, sizeof (GFC_UINTEGER_4));
+      retarray->base_addr = xmalloc (alloc_size);
       if (alloc_size == 0)
        return;
     }
@@ -158,13 +158,14 @@ minval1_s4 (gfc_array_s4 * const restrict retarray,
          memset (dest, 255, sizeof (*dest) * string_len);
        else
          {
-           for (n = 0; n < len; n++, src += delta)
+           for (n = 0; n < len; n++)
              {
 
                if (compare_fcn (src, retval, string_len) < 0)
                  {
                    retval = src;
                  }
+               src = (GFC_UINTEGER_4*) (((char*)src) + delta);
              }
            
            memcpy (dest, retval, sizeof (*dest) * string_len);
@@ -309,7 +310,7 @@ mminval1_s4 (gfc_array_s4 * const restrict retarray,
       retarray->offset = 0;
       retarray->dtype.rank = rank;
 
-      retarray->base_addr = xmallocarray (alloc_size, sizeof (GFC_UINTEGER_4));
+      retarray->base_addr = xmalloc (alloc_size);
       if (alloc_size == 0)
        return;
     }
@@ -350,7 +351,7 @@ mminval1_s4 (gfc_array_s4 * const restrict retarray,
        const GFC_UINTEGER_4 *retval;
        memset (dest, 255, sizeof (*dest) * string_len);
        retval = dest;
-       for (n = 0; n < len; n++, src += delta, msrc += mdelta)
+       for (n = 0; n < len; n++)
          {
 
                if (*msrc)
@@ -366,6 +367,8 @@ mminval1_s4 (gfc_array_s4 * const restrict retarray,
                    retval = src;
                  }
              
+           src = (GFC_UINTEGER_4*) (((char*)src) + delta);
+           msrc += mdelta;
          }
        memcpy (dest, retval, sizeof (*dest) * string_len);
       }
@@ -479,7 +482,7 @@ sminval1_s4 (gfc_array_s4 * const restrict retarray,
 
       alloc_size = GFC_DESCRIPTOR_SPACING(retarray,rank-1) * extent[rank-1];
 
-      retarray->base_addr = xmallocarray (alloc_size, sizeof (GFC_UINTEGER_4));
+      retarray->base_addr = xmalloc (alloc_size);
       if (alloc_size == 0)
        return;
     }
diff --git a/libgfortran/m4/ifunction-s2.m4 b/libgfortran/m4/ifunction-s2.m4
index b78d8d8c3846..beb3fd95ad11 100644
--- a/libgfortran/m4/ifunction-s2.m4
+++ b/libgfortran/m4/ifunction-s2.m4
@@ -30,22 +30,22 @@ compare_fcn (const atype_name *a, const atype_name *b, 
gfc_charlen_type n)
     return memcmp_char4 (a, b, n);
 }
 
-extern void name`'rtype_qual`_'atype_code (rtype * const restrict,
-        gfc_charlen_type, atype * const restrict,
+extern void 'name`'rtype_qual`_'atype_code` ('rtype` * const restrict,
+        gfc_charlen_type, 'atype` * const restrict,
        const index_type * const restrict, gfc_charlen_type);
-export_proto(name`'rtype_qual`_'atype_code);
+export_proto('name`'rtype_qual`_'atype_code`);
 
 void
-name`'rtype_qual`_'atype_code (rtype * const restrict retarray, 
-       gfc_charlen_type xlen, atype * const restrict array, 
+'name`'rtype_qual`_'atype_code` ('rtype` * const restrict retarray, 
+       gfc_charlen_type xlen, 'atype` * const restrict array, 
        const index_type * const restrict pdim, gfc_charlen_type string_len)
 {
   index_type count[GFC_MAX_DIMENSIONS];
   index_type extent[GFC_MAX_DIMENSIONS];
   index_type sspacing[GFC_MAX_DIMENSIONS];
   index_type dspacing[GFC_MAX_DIMENSIONS];
-  const atype_name * restrict base;
-  rtype_name * restrict dest;
+  const 'atype_name` * restrict base;
+  'rtype_name` * restrict dest;
   index_type rank;
   index_type n;
   index_type len;
@@ -95,7 +95,7 @@ name`'rtype_qual`_'atype_code (rtype * const restrict 
retarray,
       for (n = 0; n < rank; n++)
        {
          if (n == 0)
-           str = string_len * sizeof (rtype_name);
+           str = string_len * sizeof ('rtype_name`);
          else
            str = GFC_DESCRIPTOR_SPACING(retarray,n-1) * extent[n-1];
 
@@ -107,7 +107,7 @@ name`'rtype_qual`_'atype_code (rtype * const restrict 
retarray,
 
       alloc_size = GFC_DESCRIPTOR_SPACING(retarray,rank-1) * extent[rank-1];
 
-      retarray->base_addr = xmallocarray (alloc_size, sizeof (rtype_name));
+      retarray->base_addr = xmalloc (alloc_size);
       if (alloc_size == 0)
        return;
     }
@@ -138,7 +138,7 @@ name`'rtype_qual`_'atype_code (rtype * const restrict 
retarray,
   continue_loop = 1;
   while (continue_loop)
     {
-      const atype_name * restrict src;
+      const 'atype_name` * restrict src;
       src = base;
       {
 ')dnl
@@ -147,19 +147,20 @@ define(START_ARRAY_BLOCK,
          memset (dest, '$1`, sizeof (*dest) * string_len);
        else
          {
-           for (n = 0; n < len; n++, src += delta)
+           for (n = 0; n < len; n++)
              {
 ')dnl
 define(FINISH_ARRAY_FUNCTION,
-`            }
+`              src = ('atype_name`*) (((char*)src) + delta);
+             }
            '$1`
            memcpy (dest, retval, sizeof (*dest) * string_len);
          }
       }
       /* Advance to the next element.  */
       count[0]++;
-      base = (atype_name*) (((char*)base) + sspacing[0]);
-      dest = (rtype_name*) (((char*)dest) + dspacing[0]);
+      base = ('atype_name`*) (((char*)base) + sspacing[0]);
+      dest = ('rtype_name`*) (((char*)dest) + dspacing[0]);
       n = 0;
       while (count[n] == extent[n])
        {
@@ -168,8 +169,8 @@ define(FINISH_ARRAY_FUNCTION,
          count[n] = 0;
          /* We could precalculate these products, but this is a less
             frequently used path so probably not worth it.  */
-         base = (atype_name*) (((char*)base) - sspacing[n] * extent[n]);
-         dest = (rtype_name*) (((char*)dest) - dspacing[n] * extent[n]);
+         base = ('atype_name`*) (((char*)base) - sspacing[n] * extent[n]);
+         dest = ('rtype_name`*) (((char*)dest) - dspacing[n] * extent[n]);
          n++;
          if (n >= rank)
            {
@@ -180,22 +181,22 @@ define(FINISH_ARRAY_FUNCTION,
          else
            {
              count[n]++;
-             base = (atype_name*) (((char*)base) + sspacing[n]);
-             dest = (rtype_name*) (((char*)dest) + dspacing[n]);
+             base = ('atype_name`*) (((char*)base) + sspacing[n]);
+             dest = ('rtype_name`*) (((char*)dest) + dspacing[n]);
            }
        }
     }
 }')dnl
 define(START_MASKED_ARRAY_FUNCTION,
 `
-extern void `m'name`'rtype_qual`_'atype_code (rtype * const restrict,
-        gfc_charlen_type, atype * const restrict,
+extern void m'name`'rtype_qual`_'atype_code` ('rtype` * const restrict,
+        gfc_charlen_type, 'atype` * const restrict,
        const index_type * const restrict,
        gfc_array_l1 * const restrict, gfc_charlen_type);
-export_proto(`m'name`'rtype_qual`_'atype_code);
+export_proto(m'name`'rtype_qual`_'atype_code`);
 
 void
-`m'name`'rtype_qual`_'atype_code (rtype * const restrict retarray, 
+m'name`'rtype_qual`_'atype_code` ('rtype` * const restrict retarray, 
        gfc_charlen_type xlen, atype * const restrict array, 
        const index_type * const restrict pdim,
        gfc_array_l1 * const restrict mask,
@@ -207,8 +208,8 @@ void
   index_type sspacing[GFC_MAX_DIMENSIONS];
   index_type dspacing[GFC_MAX_DIMENSIONS];
   index_type mspacing[GFC_MAX_DIMENSIONS];
-  rtype_name * restrict dest;
-  const atype_name * restrict base;
+  'rtype_name` * restrict dest;
+  const 'atype_name` * restrict base;
   const GFC_LOGICAL_1 * restrict mbase;
   index_type rank;
   index_type dim;
@@ -220,7 +221,7 @@ void
 
   if (mask == NULL)
     {
-      name`'rtype_qual`_'atype_code (retarray, xlen, array, pdim, string_len);
+      'name`'rtype_qual`_'atype_code` (retarray, xlen, array, pdim, 
string_len);
       return;
     }
 
@@ -283,7 +284,7 @@ void
       for (n = 0; n < rank; n++)
        {
          if (n == 0)
-           str = string_len * sizeof (rtype_name);
+           str = string_len * sizeof ('rtype_name`);
          else
            str= GFC_DESCRIPTOR_SPACING(retarray,n-1) * extent[n-1];
 
@@ -295,7 +296,7 @@ void
       retarray->offset = 0;
       retarray->dtype.rank = rank;
 
-      retarray->base_addr = xmallocarray (alloc_size, sizeof (rtype_name));
+      retarray->base_addr = xmalloc (alloc_size);
       if (alloc_size == 0)
        return;
     }
@@ -326,7 +327,7 @@ void
 
   while (base)
     {
-      const atype_name * restrict src;
+      const 'atype_name` * restrict src;
       const GFC_LOGICAL_1 * restrict msrc;
 
       src = base;
@@ -334,18 +335,20 @@ void
       {
 ')dnl
 define(START_MASKED_ARRAY_BLOCK,
-`      for (n = 0; n < len; n++, src += delta, msrc += mdelta)
+`      for (n = 0; n < len; n++)
          {
 ')dnl
 define(FINISH_MASKED_ARRAY_FUNCTION,
-`        }
+`          src = ('atype_name`*) (((char*)src) + delta);
+           msrc += mdelta;
+         }
        memcpy (dest, retval, sizeof (*dest) * string_len);
       }
       /* Advance to the next element.  */
       count[0]++;
-      base = (atype_name*) (((char*)base) + sspacing[0]);
+      base = ('atype_name`*) (((char*)base) + sspacing[0]);
       mbase += mspacing[0];
-      dest = (rtype_name*) (((char*)dest) + dspacing[0]);
+      dest = ('rtype_name`*) (((char*)dest) + dspacing[0]);
       n = 0;
       while (count[n] == extent[n])
        {
@@ -354,9 +357,9 @@ define(FINISH_MASKED_ARRAY_FUNCTION,
          count[n] = 0;
          /* We could precalculate these products, but this is a less
             frequently used path so probably not worth it.  */
-         base = (atype_name*) (((char*)base) - sspacing[n] * extent[n]);
+         base = ('atype_name`*) (((char*)base) - sspacing[n] * extent[n]);
          mbase -= mspacing[n] * extent[n];
-         dest = (rtype_name*) (((char*)dest) - dspacing[n] * extent[n]);
+         dest = ('rtype_name`*) (((char*)dest) - dspacing[n] * extent[n]);
          n++;
          if (n >= rank)
            {
@@ -367,25 +370,25 @@ define(FINISH_MASKED_ARRAY_FUNCTION,
          else
            {
              count[n]++;
-             base = (atype_name*) (((char*)base) + sspacing[n]);
+             base = ('atype_name`*) (((char*)base) + sspacing[n]);
              mbase += mspacing[n];
-             dest = (rtype_name*) (((char*)dest) + dspacing[n]);
+             dest = ('rtype_name`*) (((char*)dest) + dspacing[n]);
            }
        }
     }
 }')dnl
 define(SCALAR_ARRAY_FUNCTION,
 `
-void `s'name`'rtype_qual`_'atype_code (rtype * const restrict,
-        gfc_charlen_type, atype * const restrict,
+void s'name`'rtype_qual`_'atype_code` ('rtype` * const restrict,
+        gfc_charlen_type, 'atype` * const restrict,
        const index_type * const restrict,
        GFC_LOGICAL_4 *, gfc_charlen_type);
 
-export_proto(`s'name`'rtype_qual`_'atype_code);
+export_proto(s'name`'rtype_qual`_'atype_code`);
 
 void
-`s'name`'rtype_qual`_'atype_code (rtype * const restrict retarray, 
-       gfc_charlen_type xlen, atype * const restrict array, 
+s'name`'rtype_qual`_'atype_code` ('rtype` * const restrict retarray, 
+       gfc_charlen_type xlen, 'atype` * const restrict array, 
        const index_type * const restrict pdim,
        GFC_LOGICAL_4 *mask, gfc_charlen_type string_len)
 
@@ -393,7 +396,7 @@ void
   index_type count[GFC_MAX_DIMENSIONS];
   index_type extent[GFC_MAX_DIMENSIONS];
   index_type dspacing[GFC_MAX_DIMENSIONS];
-  rtype_name * restrict dest;
+  'rtype_name` * restrict dest;
   index_type rank;
   index_type n;
   index_type dim;
@@ -401,7 +404,7 @@ void
 
   if (mask == NULL || *mask)
     {
-      name`'rtype_qual`_'atype_code (retarray, xlen, array, pdim, string_len);
+      'name`'rtype_qual`_'atype_code` (retarray, xlen, array, pdim, 
string_len);
       return;
     }
   /* Make dim zero based to avoid confusion.  */
@@ -439,7 +442,7 @@ void
       for (n = 0; n < rank; n++)
        {
          if (n == 0)
-           str = string_len * sizeof (rtype_name);
+           str = string_len * sizeof ('rtype_name`);
          else
            str = GFC_DESCRIPTOR_SPACING(retarray,n-1) * extent[n-1];
 
@@ -451,7 +454,7 @@ void
 
       alloc_size = GFC_DESCRIPTOR_SPACING(retarray,rank-1) * extent[rank-1];
 
-      retarray->base_addr = xmallocarray (alloc_size, sizeof (rtype_name));
+      retarray->base_addr = xmalloc (alloc_size);
       if (alloc_size == 0)
        return;
     }
@@ -491,7 +494,7 @@ void
     {
       memset (dest, '$1`, sizeof (*dest) * string_len);
       count[0]++;
-      dest = (rtype_name*) (((char*)dest) + dspacing[0]);
+      dest = ('rtype_name`*) (((char*)dest) + dspacing[0]);
       n = 0;
       while (count[n] == extent[n])
        {
@@ -500,14 +503,14 @@ void
          count[n] = 0;
          /* We could precalculate these products, but this is a less
             frequently used path so probably not worth it.  */
-         dest = (rtype_name*) (((char*)dest) - dspacing[n] * extent[n]);
+         dest = ('rtype_name`*) (((char*)dest) - dspacing[n] * extent[n]);
          n++;
          if (n >= rank)
            return;
          else
            {
              count[n]++;
-             dest = (rtype_name*) (((char*)dest) + dspacing[n]);
+             dest = ('rtype_name`*) (((char*)dest) + dspacing[n]);
            }
        }
     }

Reply via email to