From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27517 invoked by alias); 4 Oct 2002 18:56:02 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 27485 invoked by uid 71); 4 Oct 2002 18:56:01 -0000 Date: Fri, 04 Oct 2002 11:56:00 -0000 Message-ID: <20021004185601.27480.qmail@sources.redhat.com> To: nobody@gcc.gnu.org Cc: gcc-prs@gcc.gnu.org, From: Neil Booth Subject: Re: preprocessor/7988: POSIX broken in gcc Reply-To: Neil Booth X-SW-Source: 2002-10/txt/msg00164.txt.bz2 List-Id: The following reply was made to PR target/7988; it has been noted by GNATS. From: Neil Booth To: gcc-gnats@gcc.gnu.org Cc: Subject: Re: preprocessor/7988: POSIX broken in gcc Date: Fri, 4 Oct 2002 19:47:19 +0100 ----- Forwarded message from cs720 Administrator ----- Subject: Re: preprocessor/7988: POSIX broken in gcc From: cs720 Administrator To: Neil Booth Date: Fri, 4 Oct 2002 11:00:26 -0400 (EDT) Neil: I have some further information that should help to narrow the search for the cause of this bug. The problem seems to appear only when the stat() function is called with its second parameter, of type struct stat, allocated locally, on the stack, as in the first attachment above. If it is allocated globally, as in the second attachment, or is allocated dynamically, using malloc(), as in the third attachment, everything works fine. I hope this extra information helps locate the bug. If nothing else, it may help to to categorize it better. To me it now looks like it may be a code generator problem. Thanks, Bob Russell On Fri, 20 Sep 2002, Neil Booth wrote: > cs720 Administrator wrote:- > > > Neil: > > > > I wasn't sure how to categorize it -- > > _POSIX_C_SOURCE is a preprocessor symbol and it > > is used to select header files, define other symbols > > and structures, etc. Defining it selects one set > > of headers, etc. while not defining it selects > > another set. Perhaps the error is in the > > organization of the header files themselves, > > and the use of _POSIX_C_SOURCE within those header files. > > I doubt it is in the preprocessor itself, but > > what other category would be better? > > Um, I'll re-assign it to target. > > Neil. > /* ftype.c - program to demonstrate POSIX stat() and file-type macros */ #define _POSIX_C_SOURCE 199506L #include #include #include #include int main( int argc, char *argv[] ) { int i; char *ptr; struct stat statbuf; if( argc < 2 ) { fprintf(stderr, "Usage: ftype file1 [file2 ...]\n"); exit(EXIT_FAILURE); } for( i = 1; i < argc; i++ ) { if( stat(argv[i], &statbuf) < 0 ) perror(argv[i]); else { if( S_ISREG(statbuf.st_mode) ) ptr ="regular file"; else if( S_ISDIR(statbuf.st_mode) ) ptr ="directory"; else if( S_ISCHR(statbuf.st_mode) ) ptr ="character special file"; else if( S_ISBLK(statbuf.st_mode) ) ptr ="block special file"; else if( S_ISFIFO(statbuf.st_mode)) ptr ="FIFO file"; else ptr ="UNKNOWN FILE TYPE"; printf("%s: %s\n", argv[i], ptr); } } return EXIT_SUCCESS; } /* ftype.c - program to demonstrate POSIX stat() and file-type macros */ #define _POSIX_C_SOURCE 199506L #include #include #include #include struct stat statbuf; int main( int argc, char *argv[] ) { int i; char *ptr; if( argc < 2 ) { fprintf(stderr, "Usage: ftype file1 [file2 ...]\n"); exit(EXIT_FAILURE); } for( i = 1; i < argc; i++ ) { if( stat(argv[i], &statbuf) < 0 ) perror(argv[i]); else { if( S_ISREG(statbuf.st_mode) ) ptr ="regular file"; else if( S_ISDIR(statbuf.st_mode) ) ptr ="directory"; else if( S_ISCHR(statbuf.st_mode) ) ptr ="character special file"; else if( S_ISBLK(statbuf.st_mode) ) ptr ="block special file"; else if( S_ISFIFO(statbuf.st_mode)) ptr ="FIFO file"; else ptr ="UNKNOWN FILE TYPE"; printf("%s: %s\n", argv[i], ptr); } } return EXIT_SUCCESS; } /* ftype.c - program to demonstrate POSIX stat() and file-type macros */ #define _POSIX_C_SOURCE 199506L #include #include #include #include int main( int argc, char *argv[] ) { int i; char *ptr; struct stat *statbuf; if( argc < 2 ) { fprintf(stderr, "Usage: ftype file1 [file2 ...]\n"); exit(EXIT_FAILURE); } if( (statbuf = malloc(sizeof(struct stat))) == NULL ) { fprintf(stderr, "No space for stat buffer\n"); exit(EXIT_FAILURE); } for( i = 1; i < argc; i++ ) { if( stat(argv[i], statbuf) < 0 ) perror(argv[i]); else { if( S_ISREG(statbuf->st_mode) ) ptr ="regular file"; else if(S_ISDIR(statbuf->st_mode) ) ptr ="directory"; else if(S_ISCHR(statbuf->st_mode) ) ptr ="character special file"; else if(S_ISBLK(statbuf->st_mode) ) ptr ="block special file"; else if(S_ISFIFO(statbuf->st_mode)) ptr ="FIFO file"; else ptr ="UNKNOWN FILE TYPE"; printf("%s: %s\n", argv[i], ptr); } } return EXIT_SUCCESS; } ----- End forwarded message -----