On Fri, 19 Feb 2016 21:57:46 +0000, Yuxuan Shui wrote: > I don't think it's safe to convert between function pointer with > different number of arguments... It's possible to mess up the stack > frame.
I tested this a fair bit today, and I haven't been able to do any of the nefarious things I expected to be able to do. No overwriting variables in the caller's scope, no smashing stack pointers, etc. I was surprised by this result, but in retrospect, it's relatively obvious. The caller pushes variables onto the stack and sets the stack pointer for the callee. It wouldn't send a stack pointer that pointed into its own stack frame.