In message <[email protected]>
          "Alan Buckley" <[email protected]> wrote:

> It appears there is a bug in the C fread function in unixlib.

> I expected the feof call in the following code to return
> a non-zero value if the Testfile is less than 4096, instead
> I get zero.

> ...
>        int bytes = fread(buffer, 1, 4096, fp);
>        printf("Bytes read %d feof %d\n", bytes, (int)feof(fp));
> ...

> I was using GCC 4.1.1 (GCCSDK release 2).

> Note: In the original code I discovered this in I did check
> ferror(fp) and that was not set either.

> I'm assuming this is a bug as the documentation I have found
> on the internet on fread states feof should be set.

Yes, this looks like a UnixLib bug. If fread() returns less than the 
requested number of objects, then either feof or ferror must be set. 
The above code works as expected when using Norcroft or when using GCC 
and compiling for the SCL. It goes wrong both with static and shared 
UnixLib with GCC 4.1.1 rel2.

Martin
-- 
---------------------------------------------------------------------
Martin Wuerthner          MW Software          [email protected]
---------------------------------------------------------------------

_______________________________________________
GCCSDK mailing list [email protected]
Bugzilla: http://www.riscos.info/bugzilla/index.cgi
List Info: http://www.riscos.info/mailman/listinfo/gcc
Main Page: http://www.riscos.info/index.php/GCCSDK

Reply via email to