[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
>>> Is just casting the function pointers safe in C
>> No. As soon as you call through a pointer to the wrong type you're
>> off in nasal demon territory.
> You can't call through a function pointer of the wrong type, but you
> can cast from one type to another.
True. I wrote that with more context than the above quote gives. I
was responding to something I might flesh out as "Is just casting the
function pointers enough to make [the thing under discussion] safe in
> I think that's enough,
Maybe. It's possible I misunderstood something; I didn't go through
the whole patch in detail. But C99 does promise that....
[#8] A pointer to a function of one type may be converted to
a pointer to a function of another type and back again; the
result shall compare equal to the original pointer. If a
converted pointer is used to call a function whose type is
not compatible with the pointed-to type, the behavior is
(188.8.131.52 in the version I have).
> provided that void * is large enough to be converted to and from a
> function pointer.
I actually don't see anything that promises that a pointer to a
function type may be converted to a pointer to void, nor back again
(except, in each direction, when the original pointer is nil), much
less promising anything about the results if it is done. But I haven't
read over the whole thing recently enough to be sure there isn't such a
promise hiding somewhere.
/~\ The ASCII Mouse
\ / Ribbon Campaign
X Against HTML mouse%rodents-montreal.org@localhost
/ \ Email! 7D C8 61 52 5D E7 2D 39 4E F1 31 3E E8 B3 27 4B
Main Index |
Thread Index |