This is the mail archive of the
gcc-prs@gcc.gnu.org
mailing list for the GCC project.
c/4890: missing int-to-pointer warning
- From: gsicherm at elity dot com
- To: gcc-gnats at gcc dot gnu dot org
- Date: Fri, 16 Nov 2001 13:17:26 -0500
- Subject: c/4890: missing int-to-pointer warning
- Reply-to: gsicherm at elity dot com
[Get raw message]
>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 <stdio.h>
#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: