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

Steve Emmerson steve at groucho.ucar.edu
Sun Nov 18 13:51:49 AEST 1990


In <14517 at smoke.brl.mil> gwyn at smoke.brl.mil (Doug Gwyn) writes:

>In article <27780 at mimsy.umd.edu> chris at mimsy.umd.edu (Chris Torek) writes:
>>This would make it difficult to pass a `nil pointer to function of no
>>arguments returning int' to a function for which no prototype can be
>>provided.

>But not impossible, as a suitable pointer variable initialized to a null
>pointer (trivially accomplished) could be used.  You could even define
>it to be const-qualified and hope the compiler is good at optimizations.

Whoa!  So the following is non-conforming:

    foo((int((*)(void)))NULL)

where the prototype for foo() isn't in scope and it takes the indicated
argument type.

This has implications for those of us who, at least, *try* to write 
portable code (though, as Doug indicated, the problem is avoidable).

Are you sure of this, Doug?  Or do we need an Official Ruling?  

I know.  When in doubt, request a ruling ;-).

Steve Emmerson        steve at unidata.ucar.edu        ...!ncar!unidata!steve



More information about the Comp.lang.c mailing list