public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: c/8868: GCC 3.2, 3.2.1 fail to compile with <sys/stat.h> functions in C99 mode
@ 2002-12-08  7:26 Joseph S. Myers
  0 siblings, 0 replies; 3+ messages in thread
From: Joseph S. Myers @ 2002-12-08  7:26 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR c/8868; it has been noted by GNATS.

From: "Joseph S. Myers" <jsm28@cam.ac.uk>
To: <theaterfire@yahoo.com>
Cc: <gcc-gnats@gcc.gnu.org>,  <gcc-bugs@gcc.gnu.org>
Subject: Re: c/8868: GCC 3.2, 3.2.1 fail to compile with <sys/stat.h> functions
 in C99 mode
Date: Sun, 8 Dec 2002 15:17:06 +0000 (GMT)

 On 8 Dec 2002 theaterfire@yahoo.com wrote:
 
 > 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.
 
 This is clearly an issue with your library headers rather than with GCC.  
 If you want to claim otherwise, you'll need to provide preprocessed source
 that GCC fails to compile in C99 mode but ought to compile, or the
 collection of source files it fails to preprocess correctly in C99 mode;
 you haven't provided anything that looks like a GCC testcase.
 
 Note that, according to POSIX, this isn't a library bug either unless you
 define _POSIX_SOURCE or _POSIX_C_SOURCE to an appropriate value (depending
 on the POSIX version you want, e.g. -D_POSIX_C_SOURCE=199506L for the
 previous edition of POSIX), since -std=c99 means C standard features only,
 no POSIX features, and including <sys/stat.h> in such a mode yields
 undefined behavior.
 
 > 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>.
 
 Of course.  fileno() isn't part of C99, declaring it in strict C99 mode
 (without a feature test macro such as _POSIX_C_SOURCE) isn't allowed.
 
 -- 
 Joseph S. Myers
 jsm28@cam.ac.uk
 


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: c/8868: GCC 3.2, 3.2.1 fail to compile with <sys/stat.h> functions in C99 mode
@ 2002-12-18 12:54 ehrhardt
  0 siblings, 0 replies; 3+ messages in thread
From: ehrhardt @ 2002-12-18 12:54 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, nobody, theaterfire

Synopsis: GCC 3.2, 3.2.1 fail to compile with <sys/stat.h> functions in C99 mode

State-Changed-From-To: open->closed
State-Changed-By: cae
State-Changed-When: Wed Dec 18 12:54:08 2002
State-Changed-Why:
    Not a gcc bug (as explained by Joseph).

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=8868


^ permalink raw reply	[flat|nested] 3+ messages in thread

* c/8868: GCC 3.2, 3.2.1 fail to compile with <sys/stat.h> functions in C99 mode
@ 2002-12-07 18:26 theaterfire
  0 siblings, 0 replies; 3+ messages in thread
From: theaterfire @ 2002-12-07 18:26 UTC (permalink / raw)
  To: gcc-gnats


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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2002-12-18 20:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-12-08  7:26 c/8868: GCC 3.2, 3.2.1 fail to compile with <sys/stat.h> functions in C99 mode Joseph S. Myers
  -- strict thread matches above, loose matches on Subject: below --
2002-12-18 12:54 ehrhardt
2002-12-07 18:26 theaterfire

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).