GCC Newspaper
NOVEMBER 30, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
libgfortran

libgfortran: Correct POS after formatted STREAM read past EOR

Fixes incorrect unit position after formatted STREAM reads that go past the end of a record.

A bug in libgfortran caused incorrect positioning after formatted STREAM reads that extended beyond the end of a record. The unit position was advanced by the record terminator length for each subsequent item, leading to wrong POS= values and incorrect starting points for later reads or writes. This change corrects the counting of the record terminator, ensuring accurate positioning.

In Details

The read_block_form function in libgfortran/io/transfer.c incorrectly counted record terminators after the end of a record was detected. This patch modifies it to count the terminator only when it's consumed by the read operation. Additionally, read_x in read.c is updated to count terminators when editing like X, TR, or T extends past a record's end, ensuring stream position consistency.

Filed Under: fortranio