https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128107

--- Comment #12 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jerry DeLisle <[email protected]>:

https://gcc.gnu.org/g:56c7766c4ee32142c9ebede80bfed7ba349f958a

commit r17-6738-g56c7766c4ee32142c9ebede80bfed7ba349f958a
Author: Jerry DeLisle <[email protected]>
Date:   Thu Nov 26 09:51:06 2026 -0800

    libgfortran: [PR128107] Wrong POS after formatted STREAM read past EOR

    A formatted STREAM read whose input list goes past the end of a record
    left the unit position ahead by the record terminator length for each
    further item, so INQUIRE POS= was wrong and a later read or write at
    that position started in the wrong place.  This is because
    read_block_form counted the terminator on every call after the end of
    record was seen, although only the first call consumes it.  The patch
    counts it only on that call, and makes read_x count it as well, since
    X, TR or T editing past the end of a record consumed the terminator
    without counting it.

    Assisted-by: Claude Opus 5.5

            PR libfortran/128107

    libgfortran/ChangeLog:

            * io/read.c (read_x): Count the record terminator in the stream
            position when it is consumed.
            * io/transfer.c (read_block_form): Count the record terminator in
            the stream position only on the read that consumes it.

    gcc/testsuite/ChangeLog:

            * gfortran.dg/streamio_19.f90: New test.

Reply via email to