https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80741
--- Comment #5 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> --- Found the problem. As part of the DTIO patch we moved last_char from the dtp structure to the gfc_unit structure so that the last character read would be buffered across the parent-child procedure boundary. The presence of a character in this single character buffer is signified whenever it does not equal EOF-1. When finalizing reads or re-positioning the file such as in REWIND, we did not clear this buffer and it was holding the last character read which was EOF. I will have a full patch soon. Basically we need to put the following in strategic places: u->last_char = EOF - 1;