fstat() fails with gcc-4.1.2 experimental distribution

When I compile this program with gcc-4.1.2 experimental:

testing.c:

#include <stdio.h>
#include <sys/stat.h>

main()
{
  int status;
  struct stat st;
  FILE *f;

  f = fopen("testing.c", "r");
  printf("f: %d\n", fileno(f));

  status = fstat(fileno(f), &st);
  printf("status: %d\n", status);
}

with the command:

195% gcc -o testing testing.c
196% ./testing
f: 3
status: -1
197%

The status returned is -1. No such problem with the mingw gcc-3.4.5 compiler. Any idea why?

FstatFailure (last edited 2007-05-10 22:31:45 by dpb)