Hi Bernhard, > > +static bool > > +substring_has_constant_len (gfc_expr *e) > > +{ > > + ptrdiff_t istart, iend; > > + size_t length; > > + bool equal_length = false; > > + > > + if (e->ts.type != BT_CHARACTER > > + || !(e->ref && e->ref->type == REF_SUBSTRING) > > iff we ever can get here with e->ref == NULL then the below will not > work too well. If so then maybe > if (e->ts.type != BT_CHARACTER > || ! e->ref > || e->ref->type != REF_SUBSTRING > > ? as you already realized, the logic was fine, but probably less readable than your version. I've changed the code accordingly. > > + else if (substring_has_constant_len (e)) > > + { > > + result = gfc_get_constant_expr (BT_INTEGER, k, &e->where); > > + mpz_set_si (result->value.integer, > > + e->value.character.length); > > I think the mpz_set_si args above fit on one line. That's true. Since this block is exactly the same as for constant strings, which is handled in the first condition, I've thought some more and am convinced now that these two can be fused. Done now. I've also added two cornercases to the testcase, and regtested again. > btw.. there's a commentary typo in add_init_expr_to_sym(): > s/skeep/skip/ That is a completely unrelated issue in a different file, right? Thanks for your constructive comments! Harald