gcc and NULL function pointers.

Norman Diamond diamond at jit533.swstokyo.dec.com
Thu Jun 27 10:16:42 AEST 1991


In article <17605.Jun2607.39.3591 at kramden.acf.nyu.edu> brnstnd at kramden.acf.nyu.edu (Dan Bernstein) writes:
>In article <16506 at smoke.brl.mil> gwyn at smoke.brl.mil (Doug Gwyn) writes:
>>#defining NULL as ((char*)0) is simply wrong.
>
>By the way, I'm curious: Why is ((char *)0) ``simply wrong''? Remember
>the as-if rule: unless you can exhibit a working program whose results
>depend on whether (void *) or (char *) was used, there's no problem.

This particular argument by Mr. Bernstein seems to be correct.
I would say that #defining NULL as ((char*)0) is ugly and morally repugnant,
but not simply wrong.  A strictly conforming program could not detect if the
processor has #defined NULL as ((char*)0) (as long as the processor takes
other necessary steps in conjunction with this, such as allowing implicit
coercion to and from other pointer types).  So it seems to be allowable.
Of course, only a foolish user would write code that depends on it.
--
Norman Diamond       diamond at tkov50.enet.dec.com
If this were the company's opinion, I wouldn't be allowed to post it.
Permission is granted to feel this signature, but not to look at it.



More information about the Comp.std.c mailing list