From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1910 invoked by alias); 16 Nov 2001 18:26:01 -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 1881 invoked by uid 71); 16 Nov 2001 18:26:00 -0000 Resent-Date: 16 Nov 2001 18:26:00 -0000 Resent-Message-ID: <20011116182600.1880.qmail@sourceware.cygnus.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-To: nobody@gcc.gnu.org Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org Resent-Reply-To: gcc-gnats@gcc.gnu.org, gsicherm@elity.com Received:(qmail 32091 invoked from network); 16 Nov 2001 18:19:25 -0000 Received: from unknown (HELO elity.com) (192.41.58.136) by sourceware.cygnus.com with SMTP; 16 Nov 2001 18:19:25 -0000 Received: from sun01.elity.net ([64.80.83.114]) by elity.com (8.8.5) id LAA18337; Fri, 16 Nov 2001 11:18:22 -0700 (MST) Received: (from george@localhost) by sun01.elity.net (8.10.2+Sun/8.10.2) id fAGIHQS22965 for gcc-gnats@gcc.gnu.org; Fri, 16 Nov 2001 13:17:26 -0500 (EST) Message-Id:<20011116131726.A22951@elity.com> Date: Mon, 05 Nov 2001 13:13:00 -0000 From: gsicherm@elity.com Reply-To: gsicherm@elity.com To: gcc-gnats@gcc.gnu.org Subject: c/4890: missing int-to-pointer warning X-SW-Source: 2001-11/txt/msg00141.txt.bz2 List-Id: >Number: 4890 >Category: c >Synopsis: inconsistent int-to-pointer warning >Confidential: no >Severity: non-critical >Priority: low >Responsible: unassigned >State: open >Class: accepts-illegal >Submitter-Id: net >Arrival-Date: Fri Nov 16 10:26:00 PST 2001 >Closed-Date: >Last-Modified: >Originator: G. L. Sicherman >Release: 3.0 >Organization: Elity Systems, Inc. >Environment: System: SunOS sun01 5.8 Generic_108528-03 sun4u sparc SUNW,Ultra-5_10 Architecture: sun4 host: sparc-sun-solaris2.8 build: sparc-sun-solaris2.8 target: sparc-sun-solaris2.8 configured with: ../configure --disable-nls --disable-libgcj --enable-languages=c++,f77,objc >Description: In the Solaris 2.8 stdio.h (and GCC's hack of it), the declaration of the function fdopen is suppressed in standard C unless a suitable macro such as POSIX is defined. For classic C fdopen should probably be declared unconditionally, but Sun's conditional compilation logic still does not declare it without one of the special defines. Hence for classic C (gcc -traditional) fdopen should be undeclared and treated as int, and gcc should complain if the result is assigned to a FILE *. Gcc does not consistently complain. In fact, if I #include an empty header file after stdio.h, gcc complains correctly that an int is being assigned to a pointer. But if I #include the empty header file *before* stdio.h, gcc does not complain! Nor does it complain if I omit the empty header and include only stdio.h. The output of gcc -E is the same in both cases except for the #line marks. >How-To-Repeat: 1. Create an empty (or substantially empty) file empty.h. 2. Create this C file as rip.c: #include #include "empty.h" score() { register FILE *outf; outf = fdopen(6, "w"); } 3. Run "gcc -traditional -c rip.c". You will see this warning: rip.c: In function `score': rip.c:7: warning: assignment makes pointer from integer\ without a cast 4. Now interchange the two #include lines of rip.c and compile again. No warning appears! Here are the preprocessor outputs, left-justified. First case 3: --START-- # 1 "rip.c" # 1 "/usr/local/lib/gcc-lib/sparc-sun-solaris2.8/3.0/include/stdio.h" 1 3 # 1 "/usr/local/lib/gcc-lib/sparc-sun-solaris2.8/3.0/include/stdarg.h" 1 3 typedef __builtin_va_list __gnuc_va_list; # 135 "/usr/local/lib/gcc-lib/sparc-sun-solaris2.8/3.0/include/stdarg.h" 3 # 15 "/usr/local/lib/gcc-lib/sparc-sun-solaris2.8/3.0/include/stdio.h" 2 3 #pragma ident "@(#)stdio.h 1.78 99/12/08 SMI" # 1 "/usr/include/iso/stdio_iso.h" 1 3 #pragma ident "@(#)stdio_iso.h 1.2 99/10/25 SMI" # 1 "/usr/include/sys/feature_tests.h" 1 3 #pragma ident "@(#)feature_tests.h 1.18 99/07/26 SMI" # 1 "/usr/include/sys/isa_defs.h" 1 3 #pragma ident "@(#)isa_defs.h 1.20 99/05/04 SMI" # 267 "/usr/include/sys/isa_defs.h" 3 # 366 "/usr/include/sys/isa_defs.h" 3 # 16 "/usr/include/sys/feature_tests.h" 2 3 # 36 "/usr/include/iso/stdio_iso.h" 2 3 # 1 "/usr/include/sys/va_list.h" 1 3 #pragma ident "@(#)va_list.h 1.12 99/05/04 SMI" typedef char *__va_list; # 37 "/usr/include/iso/stdio_iso.h" 2 3 # 1 "/usr/include/stdio_tag.h" 1 3 #pragma ident "@(#)stdio_tag.h 1.3 98/04/20 SMI" typedef struct __FILE __FILE; # 38 "/usr/include/iso/stdio_iso.h" 2 3 # 1 "/usr/include/stdio_impl.h" 1 3 #pragma ident "@(#)stdio_impl.h 1.8 99/06/10 SMI" # 1 "/usr/include/sys/isa_defs.h" 1 3 # 383 "/usr/include/sys/isa_defs.h" 3 # 12 "/usr/include/stdio_impl.h" 2 3 typedef int ssize_t; # 36 "/usr/include/stdio_impl.h" 3 struct __FILE { ssize_t _cnt; unsigned char *_ptr; unsigned char *_base; unsigned char _flag; unsigned char _file; unsigned __orientation:2; unsigned __ionolock:1; unsigned __filler:5; }; # 39 "/usr/include/iso/stdio_iso.h" 2 3 typedef long long __longlong_t; typedef __FILE FILE; typedef unsigned int size_t; typedef long fpos_t; extern __FILE _iob[20 ]; # 226 "/usr/include/iso/stdio_iso.h" 3 extern int remove(); extern int rename(); extern FILE *tmpfile(); extern char *tmpnam(); extern int fclose(); extern int fflush(); extern FILE *fopen(); extern FILE *freopen(); extern void setbuf(); extern int setvbuf(); extern int fprintf(); extern int fscanf(); extern int printf(); extern int scanf(); extern int sprintf(); extern int sscanf(); extern int vfprintf(); extern int vprintf(); extern int vsprintf(); extern int fgetc(); extern char *fgets(); extern int fputc(); extern int fputs(); extern int getc(); extern int getchar(); extern char *gets(); extern int putc(); extern int putchar(); extern int puts(); extern int ungetc(); extern size_t fread(); extern size_t fwrite(); extern int fgetpos(); extern int fseek(); extern int fsetpos(); extern long ftell(); extern void rewind(); extern void clearerr(); extern int feof(); extern int ferror(); extern void perror(); extern int _filbuf(); extern int _flsbuf(); # 300 "/usr/include/iso/stdio_iso.h" 3 # 37 "/usr/local/lib/gcc-lib/sparc-sun-solaris2.8/3.0/include/stdio.h" 2 3 # 95 "/usr/local/lib/gcc-lib/sparc-sun-solaris2.8/3.0/include/stdio.h" 3 typedef long off_t; typedef __longlong_t off64_t; typedef __longlong_t fpos64_t; extern unsigned char _sibuf[], _sobuf[]; # 190 "/usr/local/lib/gcc-lib/sparc-sun-solaris2.8/3.0/include/stdio.h" 3 extern unsigned char *_bufendtab[]; extern FILE *_lastbuf; # 220 "/usr/local/lib/gcc-lib/sparc-sun-solaris2.8/3.0/include/stdio.h" 3 # 314 "/usr/local/lib/gcc-lib/sparc-sun-solaris2.8/3.0/include/stdio.h" 3 extern void setbuffer(); extern int setlinebuf(); # 347 "/usr/local/lib/gcc-lib/sparc-sun-solaris2.8/3.0/include/stdio.h" 3 # 362 "/usr/local/lib/gcc-lib/sparc-sun-solaris2.8/3.0/include/stdio.h" 3 extern int fseeko(); extern off_t ftello(); extern FILE *fopen64(); extern FILE *freopen64(); extern FILE *tmpfile64(); extern int fgetpos64(); extern int fsetpos64(); extern int fseeko64(); extern off64_t ftello64(); # 407 "/usr/local/lib/gcc-lib/sparc-sun-solaris2.8/3.0/include/stdio.h" 3 # 2 "rip.c" 2 3 # 1 "empty.h" 1 # 3 "rip.c" 2 score() { register FILE *outf; outf = fdopen(6, "w"); } --END-- Then case 4: --START-- # 1 "rip.c" # 1 "empty.h" 1 # 2 "rip.c" 2 # 1 "/usr/local/lib/gcc-lib/sparc-sun-solaris2.8/3.0/include/stdio.h" 1 3 # 1 "/usr/local/lib/gcc-lib/sparc-sun-solaris2.8/3.0/include/stdarg.h" 1 3 typedef __builtin_va_list __gnuc_va_list; # 135 "/usr/local/lib/gcc-lib/sparc-sun-solaris2.8/3.0/include/stdarg.h" 3 # 15 "/usr/local/lib/gcc-lib/sparc-sun-solaris2.8/3.0/include/stdio.h" 2 3 #pragma ident "@(#)stdio.h 1.78 99/12/08 SMI" # 1 "/usr/include/iso/stdio_iso.h" 1 3 #pragma ident "@(#)stdio_iso.h 1.2 99/10/25 SMI" # 1 "/usr/include/sys/feature_tests.h" 1 3 #pragma ident "@(#)feature_tests.h 1.18 99/07/26 SMI" # 1 "/usr/include/sys/isa_defs.h" 1 3 #pragma ident "@(#)isa_defs.h 1.20 99/05/04 SMI" # 267 "/usr/include/sys/isa_defs.h" 3 # 366 "/usr/include/sys/isa_defs.h" 3 # 16 "/usr/include/sys/feature_tests.h" 2 3 # 36 "/usr/include/iso/stdio_iso.h" 2 3 # 1 "/usr/include/sys/va_list.h" 1 3 #pragma ident "@(#)va_list.h 1.12 99/05/04 SMI" typedef char *__va_list; # 37 "/usr/include/iso/stdio_iso.h" 2 3 # 1 "/usr/include/stdio_tag.h" 1 3 #pragma ident "@(#)stdio_tag.h 1.3 98/04/20 SMI" typedef struct __FILE __FILE; # 38 "/usr/include/iso/stdio_iso.h" 2 3 # 1 "/usr/include/stdio_impl.h" 1 3 #pragma ident "@(#)stdio_impl.h 1.8 99/06/10 SMI" # 1 "/usr/include/sys/isa_defs.h" 1 3 # 383 "/usr/include/sys/isa_defs.h" 3 # 12 "/usr/include/stdio_impl.h" 2 3 typedef int ssize_t; # 36 "/usr/include/stdio_impl.h" 3 struct __FILE { ssize_t _cnt; unsigned char *_ptr; unsigned char *_base; unsigned char _flag; unsigned char _file; unsigned __orientation:2; unsigned __ionolock:1; unsigned __filler:5; }; # 39 "/usr/include/iso/stdio_iso.h" 2 3 typedef long long __longlong_t; typedef __FILE FILE; typedef unsigned int size_t; typedef long fpos_t; extern __FILE _iob[20 ]; # 226 "/usr/include/iso/stdio_iso.h" 3 extern int remove(); extern int rename(); extern FILE *tmpfile(); extern char *tmpnam(); extern int fclose(); extern int fflush(); extern FILE *fopen(); extern FILE *freopen(); extern void setbuf(); extern int setvbuf(); extern int fprintf(); extern int fscanf(); extern int printf(); extern int scanf(); extern int sprintf(); extern int sscanf(); extern int vfprintf(); extern int vprintf(); extern int vsprintf(); extern int fgetc(); extern char *fgets(); extern int fputc(); extern int fputs(); extern int getc(); extern int getchar(); extern char *gets(); extern int putc(); extern int putchar(); extern int puts(); extern int ungetc(); extern size_t fread(); extern size_t fwrite(); extern int fgetpos(); extern int fseek(); extern int fsetpos(); extern long ftell(); extern void rewind(); extern void clearerr(); extern int feof(); extern int ferror(); extern void perror(); extern int _filbuf(); extern int _flsbuf(); # 300 "/usr/include/iso/stdio_iso.h" 3 # 37 "/usr/local/lib/gcc-lib/sparc-sun-solaris2.8/3.0/include/stdio.h" 2 3 # 95 "/usr/local/lib/gcc-lib/sparc-sun-solaris2.8/3.0/include/stdio.h" 3 typedef long off_t; typedef __longlong_t off64_t; typedef __longlong_t fpos64_t; extern unsigned char _sibuf[], _sobuf[]; # 190 "/usr/local/lib/gcc-lib/sparc-sun-solaris2.8/3.0/include/stdio.h" 3 extern unsigned char *_bufendtab[]; extern FILE *_lastbuf; # 220 "/usr/local/lib/gcc-lib/sparc-sun-solaris2.8/3.0/include/stdio.h" 3 # 314 "/usr/local/lib/gcc-lib/sparc-sun-solaris2.8/3.0/include/stdio.h" 3 extern void setbuffer(); extern int setlinebuf(); # 347 "/usr/local/lib/gcc-lib/sparc-sun-solaris2.8/3.0/include/stdio.h" 3 # 362 "/usr/local/lib/gcc-lib/sparc-sun-solaris2.8/3.0/include/stdio.h" 3 extern int fseeko(); extern off_t ftello(); extern FILE *fopen64(); extern FILE *freopen64(); extern FILE *tmpfile64(); extern int fgetpos64(); extern int fsetpos64(); extern int fseeko64(); extern off64_t ftello64(); # 407 "/usr/local/lib/gcc-lib/sparc-sun-solaris2.8/3.0/include/stdio.h" 3 # 3 "rip.c" 2 3 score() { register FILE *outf; outf = fdopen(6, "w"); } --END-- >Fix: To that the elves know not the answer. -- George L. Sicherman work: gsicherm@elity.com home: colonel@mail.monmouth.com >Release-Note: >Audit-Trail: >Unformatted: