short fread(), but no ferror/feof

Peter Astrand
Fri Dec 10 12:41:00 GMT 2004

On Thu, 9 Dec 2004, Igor Pechtchanski wrote:

> > >> I've discovered that fread(ptr, size, nitems, stream) sometimes returns a
> > >> value less than "nitems", but does not set feof() nor ferror(). As I
> >
> > >A simple, compilable test case with results shown on both linux and
> > >cygwin would prove your theory.
> >
> > Here you go; example follows. Test run on Linux:

> According to <>, the
> patch was checked in on Oct 26.  Cygwin uses the latest version of newlib.
> Cygwin 1.5.12-1 was released on Nov 10, so it should contain this patch.
> You can verify this by downloading the Cygwin source package, and looking
> at newlib/libc/stdio/fread.c.

I've tested on
Cygwin, and it works. So, most probably, Cygwin uses the "fixed" newlib.

However, since my example code
( still fails, something
is still wrong. Is it possible the the "fix" above actually caused this

/Peter Åstrand <>

More information about the Newlib mailing list