Re: Fix some "call to function ... through pointer to incorrect function type" errors

Bruno Haible via Gnulib discussion list <[email protected]>
Newsgroups gmane.comp.lib.gnulib.bugs
Message-ID <24591656.BlLV05Wm1B@cagnes>
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.