Abandon NULL for (0)

Doug Gwyn gwyn at smoke.BRL.MIL
Fri Sep 22 07:06:56 AEST 1989


In article <14718 at bfmny0.UU.NET> tneff at bfmny0.UU.NET (Tom Neff) writes:
>However (0) is not explicitly cast to a pointer type, as NULL may be
>presumed to be when appropriate.

No, it may NOT be so presumed.

>For instance if I refer to, but do not declare or define, an external
>routine that accepts a single pointer as its argument, by saying
>myproc((0)), the compiler will Miranda it into a regular int, rather
>that ((void *) 0), which might have a different size and representation.

And also a different representation from the (struct foo *) that was
expected.

Passing NULL to a function (assuming no prototype in scope) without
casting it to the correct pointer type is a BUG.



More information about the Comp.lang.c mailing list