Consider this program:
int func2(char x, char y)
{
return x+y;
}
int (*fp1)(char);
void main()
{
fp1 = func2; /* func2 has one more argument than fp1 */
}
Is the final assignment C90-compliant?
Keil C51 v9.06 accepts the program without warnings, while gcc complains with
warning: assignment from incompatible pointer type
I would like to know if this a bug in the Keil compiler or in fact a C90 compliant way to deal with this.
UPDATE: According to this answer on C99, the corresponding cast is legal. But if you invoke the function pointer you get undefined behavior. Does this mean that the assignment is also legal?