https://gcc.gnu.org/g:694734c275b11823202bf8e3353ab2daf014ac57

commit 694734c275b11823202bf8e3353ab2daf014ac57
Author: Mikael Morin <[email protected]>
Date:   Wed Oct 1 14:16:22 2025 +0200

    Correction régression char_spread_1.f90

Diff:
---
 gcc/fortran/trans-array.cc | 11 +++++++++++
 gcc/fortran/trans-expr.cc  |  6 ++++--
 gcc/fortran/trans.h        |  2 ++
 3 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc
index 204f6aa5a39e..dd082901a658 100644
--- a/gcc/fortran/trans-array.cc
+++ b/gcc/fortran/trans-array.cc
@@ -2806,6 +2806,7 @@ gfc_add_loop_ss_code (gfc_loopinfo * loop, gfc_ss * ss, 
bool subscript,
            gfc_init_se (&se, NULL);
            se.loop = loop;
            se.ss = ss;
+           se.bytes_strided = info->bytes_strided;
            bool class_func = gfc_is_class_array_function (expr);
            if (class_func)
              expr->must_finalize = 1;
@@ -8003,6 +8004,16 @@ gfc_conv_expr_descriptor (gfc_se *se, gfc_expr *expr)
       gcc_assert (loop.temp_ss->dimen == loop.dimen);
       gfc_add_ss_to_loop (&loop, loop.temp_ss);
     }
+  else if (ss
+          && ss != gfc_ss_terminator
+          && ss->next == gfc_ss_terminator)
+    {
+      gfc_ss_type ss_type = ss->info->type;
+      gcc_assert (ss_type != GFC_SS_SCALAR
+                 && ss_type != GFC_SS_REFERENCE
+                 && ss_type != GFC_SS_TEMP);
+      info->bytes_strided = se->bytes_strided;
+    }
 
   gfc_conv_loop_setup (&loop, & expr->where);
 
diff --git a/gcc/fortran/trans-expr.cc b/gcc/fortran/trans-expr.cc
index 9951211a19f8..2c9affb60fc0 100644
--- a/gcc/fortran/trans-expr.cc
+++ b/gcc/fortran/trans-expr.cc
@@ -8327,7 +8327,8 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym,
                                       tmp, NULL_TREE, false,
                                       !comp->attr.pointer, callee_alloc,
                                       &se->ss->info->expr->where, true,
-                                      !IS_POINTER (comp));
+                                      !IS_POINTER (comp)
+                                      && !se->bytes_strided);
 
          /* Pass the temporary as the first argument.  */
          result = info->descriptor;
@@ -8364,7 +8365,8 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym,
                                       tmp, NULL_TREE, false,
                                       !sym->attr.pointer, callee_alloc,
                                       &se->ss->info->expr->where, true,
-                                      !IS_POINTER (sym));
+                                      !IS_POINTER (sym)
+                                      && !se->bytes_strided);
 
          /* Pass the temporary as the first argument.  */
          result = info->descriptor;
diff --git a/gcc/fortran/trans.h b/gcc/fortran/trans.h
index 7c99230c8ed5..4a8c46d81810 100644
--- a/gcc/fortran/trans.h
+++ b/gcc/fortran/trans.h
@@ -232,6 +232,8 @@ typedef struct gfc_array_info
   tree delta[GFC_MAX_DIMENSIONS];
 
   struct gfc_array_ref_info current_elem;
+
+  bool bytes_strided;
 }
 gfc_array_info;

Reply via email to