https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95947
--- Comment #5 from anlauf at gcc dot gnu.org --- The dump tree shows near the pack intrinsic: - for character(len=10): atmp.4.dtype = {.elem_len=10, .rank=1, .type=6}; atmp.4.span = 10; atmp.4.data = 0B; atmp.4.offset = 0; _gfortran_pack_char (&atmp.4, 10, D.4308, D.4328, 0B, 10, 0); - for character(len=:): atmp.5.dtype = {.elem_len=(unsigned long) slen.4, .rank=1, .type=6}; atmp.5.span = (integer(kind=8)) SAVE_EXPR <(sizetype) NON_LVALUE_EXPR <slen.4>>; atmp.5.data = 0B; atmp.5.offset = 0; slen.4 = 0; _gfortran_pack_char (&atmp.5, &slen.4, D.4314, D.4334, 0B, .n, 0); So we seem to clobber the string length before calling pack.