Hello,

Le 05/11/2022 à 23:28, Tobias Burnus a écrit :
Prior to the attached patch, there is a problem with realloc on assignment
with kind=4 characters as the string length was compared with the byte size,
which was always true.

(...)

OK for mainline?

The trans-array.c part looks good.
A couple of nits for the trans-expr.cc part:

diff --git a/gcc/fortran/trans-expr.cc b/gcc/fortran/trans-expr.cc
index e7b9211f17e..44c373cc495 100644
--- a/gcc/fortran/trans-expr.cc
+++ b/gcc/fortran/trans-expr.cc
@@ -11236,10 +11236,10 @@ alloc_scalar_allocatable_for_assignment (stmtblock_t 
*block,
if (expr1->ts.type == BT_CHARACTER && expr1->ts.deferred)
     {
-      /* Use the rhs string length and the lhs element size.  */
-      size = string_length;
-      tmp = TREE_TYPE (gfc_typenode_for_spec (&expr1->ts));
-      tmp = TYPE_SIZE_UNIT (tmp);
+      /* Use the rhs string length and the lhs element size. Note that 'size' 
is
+        used below for the string-length comparison, only.  */
+      size = string_length,
s/,/;/ ?
+      tmp = TYPE_SIZE_UNIT (gfc_get_char_type (expr2->ts.kind));
Here you are using the rhs element size, which contradicts the comment, so there is certainly something to fix here (either the comment or the code).

       size_in_bytes = fold_build2_loc (input_location, MULT_EXPR,
                                       TREE_TYPE (tmp), tmp,
                                       fold_convert (TREE_TYPE (tmp), size));

As for the testcase, do you keep the code commented on purpose?
Can some of it be removed or uncommented?

Mikael

Reply via email to