On Wed, Oct 02, 2002 at 12:51:25AM +0200, J.A. Magallon wrote:
> I have a little question. Let's suppose you have this:
>
> int (*pf)(data *);
> int f(data*);
>
> so you can:
>
> pf = f;
> pf(data).
>
> Fine. But what happens if:
>
> void (*pf)(data *);
> int f(data*);
>
> pf = f; // gcc happily swallows, gcc-3.2 gives a warning.
> pf(data).
>
> ??
>
> In C calling convention, the callee kills the stack so nothing should
> happen... or it should ?
>
I think that under most calling conventions return values are put into
registers, so this shouldn't do anything other than keep the compiler from
reallocating the designated return register for a while.
Or, after a second or two of more thought, it might cause the function to trash
whatever value is contained in the return register, which the compiler thought
was safe from harm. It all depends on the calling convention and whether the
caller assumes that the callee can destroy any registers or if the callee has to
save and restore the registers it uses.
burton
This archive was generated by hypermail 2b29 : Mon Oct 07 2002 - 22:00:30 EST