https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62215
--- Comment #4 from Tobias Burnus <burnus at gcc dot gnu.org> --- Comment on attachment 33373 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=33373 Patch to delete existing .mod file prior to updating > /* Module file have changed, replace the old one. */ >+ if (unlink (filename) && errno != ENOENT) >+ gfc_fatal_error ("Can't delete module file '%s': %s", filename, >+ xstrerror (errno)); >+ > if (rename (filename_tmp, filename)) > gfc_fatal_error ("Can't rename module file '%s' to '%s': %s", > filename_tmp, filename, xstrerror (errno)); POSIX states: "If the link named by the new argument exists and the file's link count becomes 0 when it is removed and no process has the file open, the space occupied by the file shall be freed and the file shall no longer be accessible. If one or more processes have the file open when the last link is removed, the link shall be removed before rename() returns, but the removal of the file contents shall be postponed until all references to the file are closed." Thus, I wonder whether one should use an #ifdef instead of simply reinstating the previous version. For instance, "#ifdef __MINGW32__". (I don't know what __CYGWIN__ does, nor whether any other platform has the same issues.)