diff --git a/flang/runtime/unit.cpp b/flang/runtime/unit.cpp --- a/flang/runtime/unit.cpp +++ b/flang/runtime/unit.cpp @@ -527,6 +527,11 @@ } else { // Unformatted stream: nothing to do } + } else if (handler.GetIoStat() != IostatOk && + furthestPositionInRecord == 0) { + // Error in formatted variable length record, and no output yet; do + // nothing, like most other Fortran compilers do. + return true; } else { // Terminate formatted variable length record const char *lineEnding{"\n"};