https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104128

--- Comment #6 from anlauf at gcc dot gnu.org ---
The remaining issues in this PR seem to be related to inconsistencies
between expr->representation.string and expr->value.character.string
that occur for non-default character kind that are created in gfc_copy_expr.

Hackish fix to avoid converting the (bytewise) representation.string for
non-default character kind:

diff --git a/gcc/fortran/expr.cc b/gcc/fortran/expr.cc
index 279d9b30991..ed82a94022f 100644
--- a/gcc/fortran/expr.cc
+++ b/gcc/fortran/expr.cc
@@ -312,7 +312,8 @@ gfc_copy_expr (gfc_expr *p)
          break;

        case BT_CHARACTER:
-         if (p->representation.string)
+         if (p->representation.string
+             && p->ts.kind == gfc_default_character_kind)
            q->value.character.string
              = gfc_char_to_widechar (q->representation.string);
          else

Needs regtesting.

Reply via email to