diff --git a/flang/runtime/edit-output.cpp b/flang/runtime/edit-output.cpp index eca27e3e2c0cf..fd9b70f753d88 100644 --- a/flang/runtime/edit-output.cpp +++ b/flang/runtime/edit-output.cpp @@ -21,7 +21,11 @@ static bool EditBOZOutput(IoStatementState &io, const DataEdit &edit, const unsigned char *data0, std::size_t bytes) { int digits{static_cast((bytes * 8) / LOG2_BASE)}; int get{static_cast(bytes * 8) - digits * LOG2_BASE}; - get = get ? get : LOG2_BASE; + if (get > 0) { + ++digits; + } else { + get = LOG2_BASE; + } int shift{7}; int increment{isHostLittleEndian ? -1 : 1}; const unsigned char *data{data0 + (isHostLittleEndian ? bytes - 1 : 0)};