is (int (*)())NULL legal when NULL is (void *)0?
Christopher R Volpe
volpe at camelback.crd.ge.com
Thu Nov 15 05:00:32 AEST 1990
In article <14457 at smoke.brl.mil>, gwyn at smoke.brl.mil (Doug Gwyn) writes:
|>In article <1391 at gtx.com> randy at gtx.UUCP (Randy D. Miller) writes:
|>-Can NULL always be cast to a function pointer, even in implementations
|>-that legally define NULL as (void *)0? For example, are the following
|>-lines legal?
|>- /* example 1 */ int (*f1)(void) = NULL;
|>- /* example 2 */ int (*f2)(void) = (int (*)(void))NULL;
|>
|>No, the second is not required to be supported by the implementation,
|>but the first is (3.2.2.3).
What's wrong with the second example? A null pointer constant
represented by "(void *)0" is first cast to a function pointer (perfectly
legal), and the resulting expression is assigned to the variable
f2, of identical type, which should also be legal. Can you explain the
problem?
==================
Chris Volpe
G.E. Corporate R&D
volpecr at crd.ge.com
More information about the Comp.lang.c
mailing list