Skip to content

Commit 06b3144

Browse files
authored
[flang][runtime] Clear last record in internal WRITE even if nothing … (#74528)
…was written At the end of an internal output statement, The I/O runtime fills (the remainder of) the current record with blanks if it's the only record or if anything had been written to it. This turns out to be wrong in the case of a format that ends with an explicit advance to the next record, which needs to be cleared even if nothing has been written. Fixes llvm-test-suite/Fortran/gfortran/regression/arrayio_1.f90.
1 parent a439ef5 commit 06b3144

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

flang/runtime/internal-unit.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,9 @@ InternalDescriptorUnit<DIR>::InternalDescriptorUnit(
4343

4444
template <Direction DIR> void InternalDescriptorUnit<DIR>::EndIoStatement() {
4545
if constexpr (DIR == Direction::Output) {
46-
// Clear the remainder of the current record if anything was written
47-
// to it, or if it is the only record.
46+
// Clear the remainder of the current record.
4847
auto end{endfileRecordNumber.value_or(0)};
49-
if (currentRecordNumber < end &&
50-
(end == 2 || furthestPositionInRecord > 0)) {
48+
if (currentRecordNumber < end) {
5149
BlankFillOutputRecord();
5250
}
5351
}

0 commit comments

Comments
 (0)