Skip to content

Commit 18a698a

Browse files
klauslerjeanPerier
authored andcommitted
[flang] Revert new unintended runtime behavior
A recent change caused some variable-length sequential formatted output statements with record positioning at the end of a FORMAT (e.g., FORMAT('hi',10X) to append blanks at the end of the completed record when emitting it.
1 parent 90b4cd0 commit 18a698a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

flang/runtime/unit.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,7 @@ bool ExternalFileUnit::AdvanceRecord(IoErrorHandler &handler) {
455455
furthestPositionInRecord = *recordLength;
456456
}
457457
if (!(isFixedRecordLength && access == Access::Direct)) {
458+
positionInRecord = furthestPositionInRecord;
458459
if (isUnformatted.value_or(false)) {
459460
// Append the length of a sequential unformatted variable-length record
460461
// as its footer, then overwrite the reserved first four bytes of the
@@ -464,7 +465,6 @@ bool ExternalFileUnit::AdvanceRecord(IoErrorHandler &handler) {
464465
// headers &/or footers
465466
std::uint32_t length;
466467
length = furthestPositionInRecord - sizeof length;
467-
positionInRecord = furthestPositionInRecord;
468468
ok = ok &&
469469
Emit(reinterpret_cast<const char *>(&length), sizeof length,
470470
sizeof length, handler);

0 commit comments

Comments
 (0)