From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30048 invoked by alias); 20 Sep 2002 15:06:03 -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 30014 invoked by uid 71); 20 Sep 2002 15:06:01 -0000 Resent-Date: 20 Sep 2002 15:06:01 -0000 Resent-Message-ID: <20020920150601.30013.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org Resent-Reply-To: gcc-gnats@gcc.gnu.org, cs720@unh.edu Received: (qmail 29545 invoked from network); 20 Sep 2002 15:04:04 -0000 Received: from unknown (HELO hypatia.unh.edu) (132.177.137.23) by sources.redhat.com with SMTP; 20 Sep 2002 15:04:04 -0000 Received: from hypatia.unh.edu (cs720@localhost [127.0.0.1]) by hypatia.unh.edu (8.12.6/8.12.6) with ESMTP id g8KF3fxt518477; Fri, 20 Sep 2002 11:03:41 -0400 (EDT) Received: (from cs720@localhost) by hypatia.unh.edu (8.12.6/8.12.1/Submit) id g8KF3e1v518556; Fri, 20 Sep 2002 11:03:40 -0400 (EDT) Message-Id: <200209201503.g8KF3e1v518556@hypatia.unh.edu> Date: Fri, 20 Sep 2002 08:06:00 -0000 From: cs720@unh.edu To: gcc-gnats@gcc.gnu.org Cc: rdr@unh.edu, pas@unh.edu X-Send-Pr-Version: 3.113 Subject: preprocessor/7988: POSIX broken in gcc X-SW-Source: 2002-09/txt/msg00596.txt.bz2 List-Id: >Number: 7988 >Category: preprocessor >Synopsis: Programs defining _POSIX_C_SOURCE compile but won't run >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: wrong-code >Submitter-Id: net >Arrival-Date: Fri Sep 20 08:06:01 PDT 2002 >Closed-Date: >Last-Modified: >Originator: cs720 Administrator >Release: 3.2 >Organization: University of New Hampshire >Environment: System: OSF1 hypatia.unh.edu V5.1 1885 alpha Machine: alpha host: alphaev56-dec-osf5.1 build: alphaev56-dec-osf5.1 target: alphaev56-dec-osf5.1 configured with: ../gcc-3.2/configure >Description: Many of my programs contain the line #define _POSIX_C_SOURCE 199506L before all #include lines. These used to work (over 1 year ago). Now they compile but give Segmentation faults or wrong answers when run. >How-To-Repeat: Attached below is a sample program called ftype.c If I compile it with "gcc ftype.c" and then run it with "a.out /dev/tty" it gives me a segmentation fault. If I compile it with "gcc -O ftype.c" and then run it with "a.out /dev/tty" it produces the output "/dev/tty: UNKNOWN FILE TYPE" which is the wrong answer. If I delete the line defining _POSIX_C_SOURCE and compile it with "gcc ftype.c" or "gcc -O ftype.c" and then run it with "a.out /dev/tty" it procudes the output "/dev/ttyp: character special file" which is the correct answer. /***********************************************************************/ /* 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; } /***********************************************************************/ >Fix: Just delete the line defining _POSIX_C_SOURCE. However, this worked in previous versions of gcc on OSF systems, and continues to work in current versions of gcc on Linux and Solaris systems. >Release-Note: >Audit-Trail: >Unformatted: