home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / gnu / gcc / bug / 2246 < prev    next >
Encoding:
Text File  |  1992-09-02  |  3.4 KB  |  96 lines

  1. Newsgroups: gnu.gcc.bug
  2. Path: sparky!uunet!cis.ohio-state.edu!tamri.com!kevin
  3. From: kevin@tamri.com (Kevin Dalley)
  4. Subject: Questionable warning for prototype functions with void* arguments
  5. Message-ID: <KEVIN.92Sep2183051@polkacide.tamri.com>
  6. Sender: gnulists@ai.mit.edu
  7. Reply-To: kevin@tamri.com
  8. Organization: TOSHIBA America MRI, South San Francisco, CA
  9. Distribution: gnu
  10. Date: Thu, 3 Sep 1992 01:30:55 GMT
  11. Approved: bug-gcc@prep.ai.mit.edu
  12. Lines: 82
  13.  
  14. gcc-2.2.2 gives a warning message that I believe is incorrect on the
  15. source code included below.  I configured gcc with mips-sgi-irix4.
  16. I'm using an SGI 4D/35 running Irix 4.0.1.  I have applied a few patches, but
  17. none of them seem relevant here.  Here's the code.
  18.  
  19. typedef void (*voidfunc_t)(void *);
  20.  
  21. void fred (void *a)
  22. {
  23. }
  24.  
  25. void ethel(int *a)
  26. {
  27. }
  28.  
  29. void lucy(int a)
  30. {
  31. }
  32.  
  33. void ricky(voidfunc_t func, void *a)
  34. {
  35.     (*func)(a);
  36. }
  37.  
  38. int main()
  39. {
  40.     int a;
  41.     void *b;
  42.     b = &a;
  43.     ethel(b);
  44.     fred(&a);
  45.     ricky(fred, &a);
  46.     ricky(ethel, &a);
  47.     ricky(lucy, a);
  48. }
  49.  
  50. The output from running gcc, including the warning messages look like
  51. this:
  52.  
  53. % cd /usr/people/kevin/tmp/bugs/gcc/; gcc -v fred.c
  54. setp: command not found
  55. re_t: command not found
  56. Reading specs from /usr/local/lib/gcc-lib/mips-sgi-irix4/2.2.2/specs
  57. gcc version 2.2.2
  58.  /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
  59. GNU CPP version 2.2.2 [AL 1.1, MM 19] Silicon Graphics Mips
  60.  /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
  61. GNU C version 2.2.2 [AL 1.1, MM 19] Silicon Graphics Mips compiled by GNU C version 2.2.2.
  62. fred.c: In function `main':
  63. fred.c:28: warning: passing arg 1 of `ricky' from incompatible pointer type
  64. fred.c:29: warning: passing arg 1 of `ricky' from incompatible pointer type
  65. fred.c:29: warning: passing arg 2 of `ricky' makes pointer from integer without a cast
  66.  as -nocpp -v -o fred.o /usr/tmp/cca21511.s
  67. /usr/lib/as0 -v -G 8 -EB -g0 -O1 /usr/tmp/cca21511.s -o /tmp/ctmaa21514 -t /tmp/ctmsta21514 
  68. as0: fred ethel lucy ricky main 
  69. 0.03u 0.03s 0:00.1 60%
  70. /usr/lib/as1 -v -G 8 -p0 -EB -g0 -O1 /tmp/ctmaa21514 -o fred.o -t /tmp/ctmsta21514 
  71. as1: fred ethel lucy ricky main 
  72. 0.02u 0.05s 0:00.1 54%
  73.  /usr/local/lib/gcc-lib/mips-sgi-irix4/2.2.2/mips-tfile -v -o fred.o /usr/tmp/cca21511.s
  74. mips-tfile version 2.2.2 [AL 1.1, MM 19] Silicon Graphics Mips
  75.  /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
  76.  
  77. Done 17:49:25
  78.  
  79.  
  80.  
  81. I'm not absolutely positive, but I believe that the first warning (for
  82. line 28) is incorrect.  Just as it is acceptable to call "ethel(b)"
  83. where b is void *, I think that it should be acceptable to call
  84. "ricky(ethel, &a)" since ethel is compatible with type voidfunc_t.
  85. Thus the warning for line 28 should not be there.  The warnings for
  86. line 29 are valid since an int is not compatible with a void *.
  87. I just added line 29 for comparison with line 28.
  88.  
  89. --
  90. Kevin Dalley
  91. Toshiba America MRI, Inc.
  92. kevin@tamri.com
  93.  
  94.  
  95.  
  96.