http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47694
Tobias Burnus <burnus at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |wrong-code Status|UNCONFIRMED |NEW Last reconfirmed| |2011.02.14 14:54:08 Ever Confirmed|0 |1 --- Comment #5 from Tobias Burnus <burnus at gcc dot gnu.org> 2011-02-14 14:54:08 UTC --- I have now added in io/unix.c's raw_read the following: fprintf(stderr, "raw_read - buf size: %d\n", (int) nbyte); n = read (s->fd, buf, nbyte); fprintf(stderr, " .... read %d, '", (int) n); for (i = 0; i < n; i++) fprintf(stderr, "%c", ((char*) buf)[i]); fprintf(stderr, "'\n"); return n; If I now paste in "cat > tmpfifo" the following: line 1 line 2 line 3 line 4 <no linebreak> I see on the other side: raw_read - buf size: 1024 .... read 14, 'line 1 line 2 ' 1 line 1 raw_read - buf size: 1017 .... read 7, 'line 3 ' 2 line 2 raw_read - buf size: 1017 Thus, "raw_read" reads two lines at once - but gfortran only outputs one line. For the next Fortran READ, "raw-read" is again invoked although in the buffer there is still the second half of the first read: The second line including a terminating line break. Thus, the Fortran output lags one line behind. Expected: gfortran first uses the buffer and invokes read_raw only if the buffer does not contain sufficient data (e.g. not a full line ending with a line break).