https://gcc.gnu.org/g:63e98c88e0d2192c17e58e5deefa8c8013b03232

commit 63e98c88e0d2192c17e58e5deefa8c8013b03232
Author: Mikael Morin <[email protected]>
Date:   Sat Nov 7 22:31:44 2026 +0100

    Initialisation span dans trans_arrayfunc_assign et mise à jour reshape
    
    Correction pr100194

Diff:
---
 gcc/fortran/trans-expr.cc                | 19 +++++++++++--------
 libgfortran/intrinsics/reshape_generic.c |  1 +
 libgfortran/m4/reshape.m4                |  1 +
 3 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/gcc/fortran/trans-expr.cc b/gcc/fortran/trans-expr.cc
index 289ae0311fa5..7ba4f75d9f9d 100644
--- a/gcc/fortran/trans-expr.cc
+++ b/gcc/fortran/trans-expr.cc
@@ -12723,11 +12723,15 @@ fcncall_realloc_result (gfc_se *se, int rank, tree 
dtype)
   /* Check that the shapes are the same between lhs and expression.
      The evaluation of the shape is done in 'shape_block' to avoid
      uninitialized warnings from the lhs bounds. */
-  not_same_shape = boolean_false_node;
+  tree tmp1;
+  tmp = gfc_conv_descriptor_span_get (desc);
+  tmp1 = gfc_conv_descriptor_span_get (res_desc);
+  tmp = fold_build2_loc (input_location, NE_EXPR,
+                        gfc_array_index_type, tmp, tmp1);
   gfc_start_block (&shape_block);
+  not_same_shape = gfc_evaluate_now (tmp, &shape_block);
   for (n = 0 ; n < rank; n++)
     {
-      tree tmp1;
       tmp = gfc_conv_descriptor_lbound_get (desc, gfc_rank_cst[n]);
       tmp1 = gfc_conv_descriptor_lbound_get (res_desc, gfc_rank_cst[n]);
       tmp = fold_build2_loc (input_location, MINUS_EXPR,
@@ -12742,12 +12746,9 @@ fcncall_realloc_result (gfc_se *se, int rank, tree 
dtype)
                             logical_type_node, tmp,
                             gfc_index_zero_node);
       tmp = gfc_evaluate_now (tmp, &shape_block);
-      if (n == 0)
-       not_same_shape = tmp;
-      else
-       not_same_shape = fold_build2_loc (input_location, TRUTH_OR_EXPR,
-                                         logical_type_node, tmp,
-                                         not_same_shape);
+      not_same_shape = fold_build2_loc (input_location, TRUTH_OR_EXPR,
+                                       logical_type_node, tmp,
+                                       not_same_shape);
     }
 
   /* 'zero_cond' being true is equal to lhs not being allocated or the
@@ -12794,6 +12795,8 @@ fcncall_realloc_result (gfc_se *se, int rank, tree 
dtype)
     }
 
   gfc_conv_descriptor_offset_set (&se->post, desc, offset);
+  gfc_conv_descriptor_span_set (&se->post, desc,
+                               gfc_conv_descriptor_span_get (res_desc));
 }
 
 
diff --git a/libgfortran/intrinsics/reshape_generic.c 
b/libgfortran/intrinsics/reshape_generic.c
index 44cb06b573bf..948416acf60f 100644
--- a/libgfortran/intrinsics/reshape_generic.c
+++ b/libgfortran/intrinsics/reshape_generic.c
@@ -99,6 +99,7 @@ reshape_internal (parray *ret, parray *source, shape_type 
*shape,
          rs *= rex;
        }
       ret->offset = 0;
+      ret->span = size;
 
       if (unlikely (rs < 1))
        alloc_size = 0; /* xmalloc will allocate 1 byte.  */
diff --git a/libgfortran/m4/reshape.m4 b/libgfortran/m4/reshape.m4
index b9a1aad2dfa4..01ca0e2a4032 100644
--- a/libgfortran/m4/reshape.m4
+++ b/libgfortran/m4/reshape.m4
@@ -113,6 +113,7 @@ reshape_'rtype_ccode` ('rtype` * const restrict ret,
          rs *= rex;
        }
       ret->offset = 0;
+      ret->span = sizeof ('rtype_name`);
 
       if (unlikely (rs < 1))
         alloc_size = 0;

Reply via email to