This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Questionable warning in gcc under Linux
- To: <gcc-bugs at gcc dot gnu dot org>
- Subject: Questionable warning in gcc under Linux
- From: "Leo D. Lewis" <llewis at poci dot amis dot com>
- Date: Tue, 29 Aug 2000 16:16:32 -0600
- Cc: "Paul Petersen" <ppeterse at poci dot amis dot com>
- Organization: AMI
I am porting C code that originally ran under MS-DOS (Borland 5.01 compiler).
There were no warnings with all warnings enabled. I now get warnings
with gcc under Linux but there seems to be no associated run-time problem.
I have tried numerous syntax variations without eliminating the warnings.
The gcc compiler version is egcs-2.91.66.
The command line is:
gcc -c /data/proj/barman32/body/if1.c -g -O0 -Wall -I/data/proj/barman32/body
Partial compiler output is:
/data/proj/barman32/body/if1.c: In function `IF1Init':
/data/proj/barman32/body/if1.c:105: warning: assignment from incompatible pointer type
Fragments of the code follow:
*******Here are the prototypes and globals********
int IF1Init(int, void (*[])(), int (*[])(), char *(*[])());
void (* FunctPtrv[MAXIFTYPE][MAXIFFUNCTV])();
void ToolStartup(void);
void ToolDisplay(unsigned short chan, int subtl);
********This is where IF1Init() is called*********
if ((match = IF1Init(i, FunctPtrv[i], FunctPtri[i], FunctPtrc[i])) == TRUE)
break;
********This is IF1Init()**********
int IF1Init(int ifnum, void (*functptrv[])(), int (*functptri[])(), char *(*functptrc[])())
{
functptrv[0] = ToolStartup;
functptrv[1] = NULL;
functptrv[2] = ToolDisplay; *******This is line 105 in the code**********
.
.
.
Some observations are:
1- The warning does NOT occur when assignments are made for
functions having either a void parameter list or
having only ONE pass parameter such as ToolStartup();
2- There is no warning associated with the assignment to NULL.
3- If the trailing empty parenthesis in parameter #2 of IF1Init()
(and it's prototype) are removed the warning goes away but I'm
doubtful the compiler can then identify this as a pointer to
function. I did not check if the code would run compiled this way.
4- Parameters #3 and #4 of IF1Init() are also arrays of pointers to
function like parameter #2 but removing the same parenthesis mentioned
above do NOT eliminate warnings for corresponding assignments to
functions having greater than one pass parameter.
In summary I can find no fault with my code. It does (and has
when compiled with Borland) run with no apparent ill effects.
I find it strange that the warning instance is related to the number of pass
parameters in the function whose address is being assigned as well
as the inconsistency of warnings with syntax changes to similar
parameters being passed in IF1Init().
Any help, comments or suggestions would be appreciated.
Leo Lewis
Automation Development
American Microsystems Inc.
(208) 233-4690 ext. 6516