[PR fortran/89077, patch] - ICE using * as len specifier for character parameter
Thomas Koenig
tkoenig@netcologne.de
Thu Feb 7 21:02:00 GMT 2019
Hi Harald,
> ==> f1.f90 <==
> character(1), parameter :: u = transfer ([('a'(i:i),i=1,1)], 'x')
> print *, u
> end
This one is really strange. Looking at the tree dump, it seems we
manage to encode the expression (this also works in a module file)
without actually simplifying this.
Having said that, I think one of the things we can do is to
look at gfc_resolve_substring_charlen, which has
/* Length = (end - start + 1). */
e->ts.u.cl->length = gfc_subtract (end, start);
e->ts.u.cl->length = gfc_add (e->ts.u.cl->length,
gfc_get_int_expr (gfc_charlen_int_kind,
NULL, 1));
You could try using gfc_dep_difference (in dependency.c) to try to
calculate the string length. If that does not succeed, you can then
fall back to the gfc_subtract function.
This should work to simplify the string length for a(i:i) to one.
I think we do something like this somewhere in trans-*, but it
would be much better do do it early.
Regards
Thomas
More information about the Fortran
mailing list