Bruno Haible <[email protected]> writes:

> 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.

I think my original message made it sound like I was advocating for
adding a bunch of bogus casts. Perhaps I need to spend more time looking
at sloppier code. :)

> 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.

Interesting. Good to know. I don't think I have ever used m68k.

Collin

Reply via email to