From: Janne Blomqvist Date: Mon, 8 Jan 2018 12:12:05 +0000 (+0200) Subject: PR 78534 Regression on 32-bit targets X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=4135a21f4dc1b490446722a40ce113a0f7a28305;p=gcc.git PR 78534 Regression on 32-bit targets By switching from int to size_t in order to handle larger values, r256322 introduced a bug that manifested itself on 32-bit targets. Fixed by using the correct type to store the result of a next_array_record call. Regtested on x86_64-pc-linux-gnu and i686-pc-linux-gnu, committed to trunk as obvious. libgfortran/ChangeLog: 2018-01-08 Janne Blomqvist PR 78534, bugfix for r256322 * io/transfer.c (next_record_w): Use correct type for return value of next_array_record. From-SVN: r256337 --- diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog index d05e6c65fda..022725fdcdc 100644 --- a/libgfortran/ChangeLog +++ b/libgfortran/ChangeLog @@ -1,3 +1,9 @@ +2018-01-08 Janne Blomqvist + + PR 78534, bugfix for r256322 + * io/transfer.c (next_record_w): Use correct type for return value + of next_array_record. + 2018-01-07 Thomas Koenig * libgfortran.h (GFC_DTYPE_COPY): New macro. diff --git a/libgfortran/io/transfer.c b/libgfortran/io/transfer.c index f9c8696766f..7e076de84fa 100644 --- a/libgfortran/io/transfer.c +++ b/libgfortran/io/transfer.c @@ -3691,7 +3691,7 @@ next_record_w (st_parameter_dt *dtp, int done) { char *p; /* Internal unit, so must fit in memory. */ - size_t length, m, record; + size_t length, m; size_t max_pos = max_pos_off; if (is_array_io (dtp)) { @@ -3730,14 +3730,16 @@ next_record_w (st_parameter_dt *dtp, int done) memset (p, ' ', length); /* Now that the current record has been padded out, - determine where the next record in the array is. */ - record = next_array_record (dtp, dtp->u.p.current_unit->ls, - &finished); + determine where the next record in the array is. + Note that this can return a negative value, so it + needs to be assigned to a signed value. */ + gfc_offset record = next_array_record + (dtp, dtp->u.p.current_unit->ls, &finished); if (finished) dtp->u.p.current_unit->endfile = AT_ENDFILE; /* Now seek to this record */ - record = record * ((size_t) dtp->u.p.current_unit->recl); + record = record * dtp->u.p.current_unit->recl; if (sseek (dtp->u.p.current_unit->s, record, SEEK_SET) < 0) {