home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: gnu.gcc.bug
- Path: sparky!uunet!cis.ohio-state.edu!tamri.com!kevin
- From: kevin@tamri.com (Kevin Dalley)
- Subject: Questionable warning for prototype functions with void* arguments
- Message-ID: <KEVIN.92Sep2183051@polkacide.tamri.com>
- Sender: gnulists@ai.mit.edu
- Reply-To: kevin@tamri.com
- Organization: TOSHIBA America MRI, South San Francisco, CA
- Distribution: gnu
- Date: Thu, 3 Sep 1992 01:30:55 GMT
- Approved: bug-gcc@prep.ai.mit.edu
- Lines: 82
-
- gcc-2.2.2 gives a warning message that I believe is incorrect on the
- source code included below. I configured gcc with mips-sgi-irix4.
- I'm using an SGI 4D/35 running Irix 4.0.1. I have applied a few patches, but
- none of them seem relevant here. Here's the code.
-
- typedef void (*voidfunc_t)(void *);
-
- void fred (void *a)
- {
- }
-
- void ethel(int *a)
- {
- }
-
- void lucy(int a)
- {
- }
-
- void ricky(voidfunc_t func, void *a)
- {
- (*func)(a);
- }
-
- int main()
- {
- int a;
- void *b;
- b = &a;
- ethel(b);
- fred(&a);
- ricky(fred, &a);
- ricky(ethel, &a);
- ricky(lucy, a);
- }
-
- The output from running gcc, including the warning messages look like
- this:
-
- % cd /usr/people/kevin/tmp/bugs/gcc/; gcc -v fred.c
- setp: command not found
- re_t: command not found
- Reading specs from /usr/local/lib/gcc-lib/mips-sgi-irix4/2.2.2/specs
- gcc version 2.2.2
- /usr/local/lib/gcc-lib/mips-sgi-irix4/2.2.2/cpp -lang-c -v -undef -D__GNUC__=2 -Dunix -Dmips -Dsgi -DSVR3 -Dhost_mips -DMIPSEB -DSYSTYPE_SYSV -D__unix__ -D__mips__ -D__sgi__ -D__SVR3__ -D__host_mips__ -D__MIPSEB__ -D__SYSTYPE_SYSV__ -D__unix -D__mips -D__sgi -D__SVR3 -D__host_mips -D__MIPSEB -D__SYSTYPE_SYSV -D__CHAR_UNSIGNED__ -D__EXTENSIONS__ -D_MIPSEB -D_SYSTYPE_SYSV -D_LANGUAGE_C -DLANGUAGE_C fred.c /usr/tmp/cca21511.i
- GNU CPP version 2.2.2 [AL 1.1, MM 19] Silicon Graphics Mips
- /usr/local/lib/gcc-lib/mips-sgi-irix4/2.2.2/cc1 /usr/tmp/cca21511.i -quiet -dumpbase fred.c -version -o /usr/tmp/cca21511.s
- GNU C version 2.2.2 [AL 1.1, MM 19] Silicon Graphics Mips compiled by GNU C version 2.2.2.
- fred.c: In function `main':
- fred.c:28: warning: passing arg 1 of `ricky' from incompatible pointer type
- fred.c:29: warning: passing arg 1 of `ricky' from incompatible pointer type
- fred.c:29: warning: passing arg 2 of `ricky' makes pointer from integer without a cast
- as -nocpp -v -o fred.o /usr/tmp/cca21511.s
- /usr/lib/as0 -v -G 8 -EB -g0 -O1 /usr/tmp/cca21511.s -o /tmp/ctmaa21514 -t /tmp/ctmsta21514
- as0: fred ethel lucy ricky main
- 0.03u 0.03s 0:00.1 60%
- /usr/lib/as1 -v -G 8 -p0 -EB -g0 -O1 /tmp/ctmaa21514 -o fred.o -t /tmp/ctmsta21514
- as1: fred ethel lucy ricky main
- 0.02u 0.05s 0:00.1 54%
- /usr/local/lib/gcc-lib/mips-sgi-irix4/2.2.2/mips-tfile -v -o fred.o /usr/tmp/cca21511.s
- mips-tfile version 2.2.2 [AL 1.1, MM 19] Silicon Graphics Mips
- /usr/local/lib/gcc-lib/mips-sgi-irix4/2.2.2/ld /usr/lib/crt1.o -L/usr/local/lib/gcc-lib/mips-sgi-irix4/2.2.2 -L/usr/local/lib fred.o -lgcc -lc /usr/lib/crtn.o -lgcc
-
- Done 17:49:25
-
-
-
- I'm not absolutely positive, but I believe that the first warning (for
- line 28) is incorrect. Just as it is acceptable to call "ethel(b)"
- where b is void *, I think that it should be acceptable to call
- "ricky(ethel, &a)" since ethel is compatible with type voidfunc_t.
- Thus the warning for line 28 should not be there. The warnings for
- line 29 are valid since an int is not compatible with a void *.
- I just added line 29 for comparison with line 28.
-
- --
- Kevin Dalley
- Toshiba America MRI, Inc.
- kevin@tamri.com
-
-
-
-