https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118571
--- Comment #6 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> --- (In reply to kargls from comment #3) > diff --git a/libgfortran/io/write.c b/libgfortran/io/write.c > index 54312bf67e9..084ac314f5c 100644 > --- a/libgfortran/io/write.c > +++ b/libgfortran/io/write.c > @@ -178,7 +178,7 @@ write_utf8_char4 (st_parameter_dt *dtp, gfc_char4_t > *source, > } > > /* Now process the remaining characters, one at a time. */ > - for (j = k; j < src_len; j++) > + for (j = k; j < (w_len < src_len ? w_len : src_len); j++) > { > c = source[j]; > if (c < 0x80) The patch breaks utf8_1.f03. I have an inkling why and will get back to this in the morning.