negative addresses
Andrew Klossner
andrew at frip.gwd.tek.com
Wed May 18 03:57:43 AEST 1988
Doug Gwyn (gwyn at brl-smoke.ARPA) writes:
>> Unfortunately, it is a real problem, because there are zillions of
>> programs that implicitly assume that [null] pointers are all-zeros.
> I don't think this is true. How about an example?
Sure Doug, from the system V kernel that you defend so ardently :-),
file io/tt1.c (vanilla release 3.1):
In routine ttout:
if (tbuf->c_ptr)
appears twice. (And in the same routine,
if (tbuf->c_ptr == NULL)
appears twice. Multiple hackers have clogged through here.)
In routine ttioctl:
if (tp->t_rbuf.c_ptr) {
if (tp->t_tbuf.c_ptr) {
The C standards I've seen so far are pretty clear in stating that the
conditional is compared against zero. There doesn't seem to be leeway
to define pointer comparisons to be against some non-zero NULL value.
-=- Andrew Klossner (decvax!tektronix!tekecs!andrew) [UUCP]
(andrew%tekecs.tek.com at relay.cs.net) [ARPA]
More information about the Comp.lang.c
mailing list