Flash Gordon said:
The C standard leaves any attempt to convert between function pointers
and object (data) pointers undefined, so before you get as far as trying
to copy a function or call an array you have to invoke undefined behaviour.
I.e. there is absolutely no way to get even vaguely close to what the OP
wants without invoking undefined behaviour.
That second paragraph is not -exactly- true, at least not in C89.
In C89, the direction conversion between function pointers and
object pointers is left undefined, and like you say, that would
be "undefined behaviour".
However! If the function pointer is converted to an integer, and
the integer is then converted to an object pointer, then that would
be two operations that C89 explicitly permits, with both operation
having *implementation defined* behaviour. Thus, if one proceeds
that way, that would be "an attempt to convert between function
pointers and object (data) pointers", and it would only involve
implementation-defined behaviour rather than undefined behaviour.
Of course, implementation-defined behaviour is not necessarily
going to be -useful- behaviour. On a Harvard architecture it
would not be at all unreasonable that the result of this
conversion of a function pointer by way of an integer would be
a rogue pointer into data space rather than anything to do with
program space. So it is by no means a portable operation sequence.
(Yup, I have my fair share of confusion and mis-speaking about
"undefined behaviour" versus "implementation-defined behaviour".
This particular behaviour just happened to be one of the ones I remembered
and had my standard at hand to check.)