Skip to content

Commit 9fd03cb

Browse files
authored
[flang][runtime] Don't prematurely end formatted integer input (#76643)
When an input data-list has more items than can be read by a format from the input record (e.g., "(4I5)" reading "1 2"), don't return false from EditIntegerInput() just because nothing was read -- that will prevent later items from being set to zero, as they should be. Return true unless nothing was read and there is some kind of error pending. Fixes llvm-error-tests/Fortran/gfortran/regression/pr478478.f90.
1 parent 8fa3184 commit 9fd03cb

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

flang/runtime/edit-input.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ bool EditIntegerInput(
244244
if (sign == '-') {
245245
value = -value;
246246
}
247-
if (any || !io.GetConnectionState().IsAtEOF()) {
247+
if (any || !io.GetIoErrorHandler().InError()) {
248248
// The value is stored in the lower order bits on big endian platform.
249249
// When memcpy, shift the value to the higher order bit.
250250
auto shft{static_cast<int>(sizeof(value.low())) - kind};
@@ -255,8 +255,10 @@ bool EditIntegerInput(
255255
} else {
256256
std::memcpy(n, &value, kind); // a blank field means zero
257257
}
258+
return true;
259+
} else {
260+
return false;
258261
}
259-
return any;
260262
}
261263

262264
// Parses a REAL input number from the input source as a normalized

0 commit comments

Comments
 (0)