diff --git a/flang/runtime/io-api.cpp b/flang/runtime/io-api.cpp --- a/flang/runtime/io-api.cpp +++ b/flang/runtime/io-api.cpp @@ -826,13 +826,15 @@ } if (n <= 0) { io.GetIoErrorHandler().SignalError("RECL= must be greater than zero"); - } - if (open->wasExtant() && - open->unit().openRecl.value_or(n) != static_cast(n)) { + return false; + } else if (open->wasExtant() && + open->unit().openRecl.value_or(0) != static_cast(n)) { open->SignalError("RECL= may not be changed for an open unit"); + return false; + } else { + open->unit().openRecl = n; + return true; } - open->unit().openRecl = n; - return true; } bool IONAME(SetStatus)(Cookie cookie, const char *keyword, std::size_t length) {