https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118571
--- Comment #3 from kargls at comcast dot net --- (In reply to kargls from comment #2) > Tracing into libgfortran, the bug appears to be in write.c(write_utf8_char4). > In particular, the entire string is written due to line 181. The 'src_len' > is likely wrong if one has an A edit descriptor with a width. Perhaps, > it should be 'w_len < src_len ? w_len : src_len' > > /* Now process the remaining characters, one at a time. */ > for (j = k; j < src_len; j++) > { Seems likely the correct fix, but I don't do UTF-8 so YMMV. 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)