diff --git a/flang/runtime/io-stmt.h b/flang/runtime/io-stmt.h --- a/flang/runtime/io-stmt.h +++ b/flang/runtime/io-stmt.h @@ -189,10 +189,10 @@ if (get_if>()) { return true; } else { - if (!get_if()) { - GetIoErrorHandler().Crash( - "%s called for I/O statement that is not formatted %s", name, - D == Direction::Output ? "output" : "input"); + auto &handler{GetIoErrorHandler()}; + if (!handler.InError()) { + handler.Crash("%s called for I/O statement that is not formatted %s", + name, D == Direction::Output ? "output" : "input"); } return false; }