https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87851
Thomas Koenig <tkoenig at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jb at gcc dot gnu.org Blocks| |87711 Target Milestone|--- |8.3 --- Comment #1 from Thomas Koenig <tkoenig at gcc dot gnu.org> --- I might add that the patch I thought semi-obvious Index: iresolve.c =================================================================== --- iresolve.c (Revision 265502) +++ iresolve.c (Arbeitskopie) @@ -1518,16 +1518,42 @@ gfc_resolve_len (gfc_expr *f, gfc_expr *string, gf gfc_default_integer_kind); } +void gfc_debug_expr (gfc_expr *); void gfc_resolve_len_trim (gfc_expr *f, gfc_expr *string, gfc_expr *kind) { + int fkind; + + f->ts.type = BT_INTEGER; if (kind) - f->ts.kind = mpz_get_si (kind->value.integer); + { + fkind = mpz_get_si (kind->value.integer); + + /* Remove the kind argument. */ + gfc_free_expr (kind); + f->value.function.actual->next->expr = NULL; + + } else - f->ts.kind = gfc_default_integer_kind; + fkind = gfc_default_integer_kind; + + f->ts.kind = gfc_charlen_int_kind; f->value.function.name = gfc_get_string ("__len_trim%d", string->ts.kind); +#if 1 + if (fkind != f->ts.kind) + { + gfc_typespec ts; + gfc_clear_ts (&ts); + + ts.type = BT_INTEGER; + ts.kind = fkind; + gfc_convert_type_warn (f, &ts, 2, 0); + } +#endif + fprintf(stderr,"%d\n", fkind); + gfc_debug_expr (f); } fails on program p character(3) :: c(2) = ['abc', 'xyz'] print *, len_trim(c,4) print *, len_trim(c,8) end with a segfault somewhere in the scalarizer. Referenced Bugs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87711 [Bug 87711] ICE in gfc_trans_transfer, at fortran/trans-io.c:2676