This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
c/8868: GCC 3.2, 3.2.1 fail to compile with <sys/stat.h> functions in C99 mode
- From: theaterfire at yahoo dot com
- To: gcc-gnats at gcc dot gnu dot org
- Date: 8 Dec 2002 02:19:17 -0000
- Subject: c/8868: GCC 3.2, 3.2.1 fail to compile with <sys/stat.h> functions in C99 mode
- Reply-to: theaterfire at yahoo dot com
>Number: 8868
>Category: c
>Synopsis: GCC 3.2, 3.2.1 fail to compile with <sys/stat.h> functions in C99 mode
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sat Dec 07 18:26:01 PST 2002
>Closed-Date:
>Last-Modified:
>Originator: Tim
>Release: gcc version 3.2 (mingw special 20020817-1) and others
>Organization:
>Environment:
Configured with: ../gcc/configure --with-gcc --with-gnu-ld --with-gnu-as --host=mingw32 --target=mingw32 --prefix=/mingw --enable-threads --disable-nls --enable-languages=f77,c++,objc,ada --disable-win32-registry --disable-shared
Thread model: win32
gcc version 3.2 (mingw special 20020817-1)
>Description:
Using struct stat, stat(), or fstat() from <sys/stat.h> causes compilation to fail in gcc 3.2 under C99 mode. In some cases, it also causes errors to be reported about other functions that compile properly without the introduction of <sys/stat.h> elements.
The test program below has been tested to compile properly under gcc 2.95.3 (mingw), gcc 3.0.2 (Linux, glibc 2.1, C89 and C99), gcc 3.2 (mingw, C89), and gcc 3.2.1 (Linux, C89). It has failed testing under gcc 3.2 (Solaris, mingw, C99) and gcc 3.2.1 (Linux).
If all <sys/stat.h> elements are removed from the sample, it will properly compile in C99 mode. Note that with the <sys/stat.h> elements, gcc will also warn of implicit declaration of fileno(), included from <stdio.h>.
Unfortunately, I do not have the resources to test this behavior under the latest development snapshot.
~$ gcc -o testme testme.c -std=c99
testme.c: In function `main':
testme.c:6: storage size of `filestat' isn't known
testme.c:12: warning: implicit declaration of function `fstat'
testme.c:12: warning: implicit declaration of function `fileno'
>How-To-Repeat:
/* test_stat.c */
#include <sys/stat.h>
#include <stdio.h>
int main()
{
struct stat filestat;
FILE *openfile;
int test;
openfile = fopen("anyfile.txt", "r");
fstat(fileno(openfile), &filestat);
test = filestat.st_size;
printf("test = %d\n", test);
fclose(openfile);
return 0;
}
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted: