Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!zaphod.mps.ohio-state.edu!rpi!crdgw1!camelback!volpe From: volpe@camelback.crd.ge.com (Christopher R Volpe) Newsgroups: comp.lang.c Subject: Re: is (int (*)())NULL legal when NULL is (void *)0? Message-ID: <13799@crdgw1.crd.ge.com> Date: 14 Nov 90 18:00:32 GMT References: <1391@gtx.com> <14457@smoke.brl.mil> Sender: news@crdgw1.crd.ge.com Reply-To: volpe@camelback.crd.ge.com (Christopher R Volpe) Lines: 21 In article <14457@smoke.brl.mil>, gwyn@smoke.brl.mil (Doug Gwyn) writes: |>In article <1391@gtx.com> randy@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@crd.ge.com