public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: theaterfire@yahoo.com
To: gcc-gnats@gcc.gnu.org
Subject: c/8868: GCC 3.2, 3.2.1 fail to compile with <sys/stat.h> functions in C99 mode
Date: Sat, 07 Dec 2002 18:26:00 -0000	[thread overview]
Message-ID: <20021208021917.29516.qmail@sources.redhat.com> (raw)


>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:


             reply	other threads:[~2002-12-08  2:26 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-12-07 18:26 theaterfire [this message]
2002-12-08  7:26 Joseph S. Myers
2002-12-18 12:54 ehrhardt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20021208021917.29516.qmail@sources.redhat.com \
    --to=theaterfire@yahoo.com \
    --cc=gcc-gnats@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).