diff --git a/flang/runtime/edit-output.cpp b/flang/runtime/edit-output.cpp --- a/flang/runtime/edit-output.cpp +++ b/flang/runtime/edit-output.cpp @@ -627,9 +627,15 @@ template bool EditCharacterOutput(IoStatementState &io, const DataEdit &edit, const CHAR *x, std::size_t length) { + int len{static_cast(length)}; + int width{edit.width.value_or(len)}; switch (edit.descriptor) { case 'A': + break; case 'G': + if (width == 0) { + width = len; + } break; case 'B': return EditBOZOutput<1>(io, edit, @@ -646,8 +652,6 @@ edit.descriptor); return false; } - int len{static_cast(length)}; - int width{edit.width.value_or(len)}; return io.EmitRepeated(' ', std::max(0, width - len)) && io.EmitEncoded(x, std::min(width, len)); }