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 @@ -1280,6 +1280,9 @@ static enum Iostat CheckUnitNumberInRangeImpl(INT unit, bool handleError, char *ioMsg, std::size_t ioMsgLength, const char *sourceFile, int sourceLine) { + static_assert(sizeof(INT) >= sizeof(ExternalUnit), + "only intended to be used when the INT to ExternalUnit conversion is " + "narrowing"); if (unit != static_cast(unit)) { Terminator oom{sourceFile, sourceLine}; IoErrorHandler errorHandler{oom};