Collin Funk wrote:
> I still don't see an issue with it even though it is undefined behavior,

It's a nice way to shoot yourself in the foot and spend time debugging,
because
  - the function is defined in one place,
  - the cast (possibly via a union!) is in a different place,
  - the call site is in a third place.
And typically you don't get any warnings about these things.

There are packages where converting function pointers, possibly via
'void *', is intentional and well implemented. But in the majority
of application code, it is a dangerous thing to do.

You would think converting a   int (*) (char *)
to                             int (*) (uintptr_t)
is OK? Fail! On m68k, the first one passes its argument in register A0,
whereas the second one passes its argument in register D0.

Bruno




Reply via email to