http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59419
--- Comment #4 from Janne Blomqvist <jb at gcc dot gnu.org> --- Indeed I suspect we have many cases in the IO library where stuff fails, leaks memory, or leaves stuff in an inconsistent state when IOSTAT= is present. I think that we should modify generate_error() to not terminate the program in case IOSTAT= is not present, but instead we return and unwind the IO call stack (manually with return statements since this is plain old C), and then only at the end just before we return to the user Fortran program we check IOPARM_HAS_IOSTAT and IOPARM_LIBRETURN_MASK and exit() if appropriate. That way error handling works the same whether IOSTAT= is present or not. But such a change is probably 4.10 material.