is (int (*)())NULL legal when NULL is (void *)0?

Barry Margolin barmar at think.com
Fri Nov 16 07:48:58 AEST 1990


In article <14463 at smoke.brl.mil> gwyn at smoke.brl.mil (Doug Gwyn) writes:
>A null pointer constant can be safely compared to a pointer to function,
>and it can be safely assigned to a pointer to function modifiable lvalue,
>but that's it.  Casting a null pointer constant to pointer to function is
>not permitted in a strictly conforming program.

I thought that the semantics of casting were equivalent to that of
assignment to an object of the given type.  So how can an assignment be
valid but the corresponding cast be invalid?  Or is this equivalence an old
rule of thumb that isn't precisely correct?  Are there other examples of
assignments that don't have corresponding casts or vice versa?


--
Barry Margolin, Thinking Machines Corp.

barmar at think.com
{uunet,harvard}!think!barmar



More information about the Comp.lang.c mailing list