Andrew Haley wrote:
> Mark Mitchell writes:
>  > 
>  > I also agree with Gaby that we should document this as an extension.  If
>  > we go to the work of putting it back in, we should ensure that it
>  > continues to work for the foreseeable future.  Part of that is writing
>  > down what we've decided.
> 
> We can't make function pointer type casts work in the general case, as
> we know; all we can promise to do is make our best effort.  How can we
> document that?  

We can say something like:

"In GNU C, you may cast a function pointer of one type to a function
pointer of another type.  If you use a function pointer to call a
function, and the dynamic type of the function pointed to by the
function pointer is not the same as indicated by the static type of the
function pointer, then the results of the call are unspecified.  In
general, if the types are not too different (e.g., the dynamic type is
"void ()(unsigned int)" while the static type is "void ()(int)"), then
the results of the call will probably be as you expect.  However, if the
types are sufficiently different, there is no guarantee that your
program will behave in any predictable fashion."

The use of "unspecified" here (as opposed to "undefined") indicates
that, while we're not saying what happens, we're also suggesting that
this is a more benign issue.

-- 
Mark Mitchell
CodeSourcery
[EMAIL PROTECTED]
(650) 331-3385 x713

Reply via email to