Problem 4 began with a collection of function prototypes.
int f(int m, int n, int *o) ; int g(int *p, int *q) ; int h(int **r, int s) ;
Along with these were a few variable declarations.
int a ; int *b ; int c[15] ;
The intent of the question was to discover problems with passing
parameter of incompatible types. For example, both parameters
of g are of type int *, pointers
to integers. This that compatible parameters for b
include &a and b and even, due
to the way C treats arrays as pointers, c and
c+10. However, neither a
or &b would be compatible.
The problem with the question is the C is very forgiving of incompatible parameters and is willing to just issue a warning to all sorts of implausable parameters. Unfortunately, the question asked when a potential call was "not legal" in C rather than when it involved silly parameters. Technically, all the calls but one (which attempted to pass two paramters to a function needed three) were legal.
It was difficult to undercover the intent of the person answering the question. We're they looking for illegal or unwise parameter passing? Consequently, I dropped the question from the exam and gave everyone a free nine points.
On the Intel chip, when incompatible pointers are passed to a function, the compiler just passes in the address which, of course, points to the wrong time. Presumably the called function then performs some nonsensical action.
In none of these examples was an integer passed to a paramter expecting a pointer or vice versa. However, I tried that one out. On 32-bit Intel chips, the 32-bit values are just copied directly from pointer to integer. On 64-bit Intel chips, pointers are twice the size of integers. Here, simple bit extension of truncation is used to "solve" the problem.