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

Fix formatted input positioning for T, TL, and X edits

Libgfortran's formatted input now correctly handles tab and position edits that extend past the end of a record.

This change corrects an issue in libgfortran’s formatted input handling where tab (T, TL) and position (X) edits could misbehave when extending past the end of a record. A new read_tab function centralizes positioning logic, correctly handling positions beyond record boundaries and ensuring accurate data reading, especially with STREAM units.

In Details

The formatted_transfer_scalar_read routine in libgfortran's io/transfer.c previously mishandled formatted input positioning for X, T, and TL edits when the requested position exceeded the current record's length. This led to incorrect state being maintained, causing subsequent edits to read incorrectly or nothing at all. A new read_tab function is introduced to consolidate this logic, ensuring proper handling of positions past the record end and correct management of the end-of-record flag. STREAM units now flush their format buffer at the start of reads to establish a consistent…

For Context
STREAM unit
A Fortran I/O unit that operates on a continuous sequence of records, typically used for sequential access files.
formatted input
Reading data from a file using format specifiers that control the layout and type of the data being read.
T, TL, X edits
Fortran format specifiers for positioning within a record: T positions to a character count, TL positions left of the current character, and X skips characters.
Filed Under: fortraniobugfix