On 28.11.20 23:16, Harald Anlauf wrote:

When substituting an array-valued character parameter variable, the call to
gfc_copy_expr returns character length 1.  Fix up the resulting length.
[...]
I disagree.
@@ -2096,6 +2096,10 @@ simplify_parameter_variable (gfc_expr *p, int type)
        return false;

        e->rank = p->rank;
+
+      /* Fix up character length since gfc_copy_expr may not preserve it.  */
+      if (e->ts.type == BT_CHARACTER && p->ts.u.cl)
+       e->ts.u.cl = gfc_new_charlen (gfc_current_ns, p->ts.u.cl);

The comment looks wrong and I think also that the fix is at the wrong place.
  else
    {
      e = gfc_copy_expr (p->symtree->n.sym->value);
...

Here, "p" is "s(AR_FULL)". p->symtree->n.sym's ts.u.cl also has the correct 
length; the only problem is that
'p->symtree->n.sym->value' has the wrong length.

The question is what sets the wrong string length of 1? I think that should be 
fixed.
As band aid, you could use:
 e->ts = p->ts;
or
 e->ts = p->symtree->n.sym->ts;
or either of those but with '.u.cl' appended + a FIXME comment
that '->value->ts.u.cl' might be wrong.

That is acceptable to me.

But I am against the current patch – it pointlessly duplicates
the string length variable and the comment is completely misleading
as it is fake news.

Tobias

Reply via email to