gcc and NULL function pointers.

Rahul Dhesi dhesi at cirrus.com
Fri Jun 28 05:01:07 AEST 1991


In <17605.Jun2607.39.3591 at kramden.acf.nyu.edu>
brnstnd at kramden.acf.nyu.edu (Dan Bernstein) writes:

>'Scuse me for thinking about backwards compatibility in a standards
>group.

Good point!  Let's keep this in mind.

>By the way, I'm curious: Why is ((char *)0) ``simply wrong''?

It's wrong for the same reason that ((void *) 0) is wrong.  K&R said
that NULL is defined to be 0.  Therefore existing code that (unwisely)
uses NULL to stand for a zero in a non-pointer context may break using
either ((void *) 0) or ((char *) 0).

However, ((void *) 0) is blessed by ANSI and ((char *) 0) is not.
Therefore we may summarize:

     ((void *) 0) is ANSI-conformant but wrong.
     ((char *) 0) is not ANSI-conformant and wrong.

And the bottom line:

     All definitions of NULL other than 0 are wrong, no matter how
     much or how little ANSI-conformant they may be.
-- 
Rahul Dhesi <dhesi at cirrus.COM>
UUCP:  oliveb!cirrusl!dhesi



More information about the Comp.std.c mailing list