Newsgroups: comp.os.minix
Path: utzoo!henry
From: henry@utzoo.uucp (Henry Spencer)
Subject: Re: NULL
Message-ID: <1989Nov18.234616.23977@utzoo.uucp>
Organization: U of Toronto Zoology
References: <4555@math.cs.vu.nl>
Date: Sat, 18 Nov 89 23:46:16 GMT

In article <4555@math.cs.vu.nl> keie@cs.vu.nl (Ed Keizer) writes:
>4-  The opinion of Henry Spencer that a cast of 0 to any other pointer
>    type than `void *' is illegal and pointless, is incorrect.

There is nothing wrong with casting 0 to any pointer type; however, this
is not a legal definition for NULL.  4.1.5 says NULL must be a "null
pointer constant".  This is *not* an informal term with whatever meaning
an implementation chooses to give it:  it is precisely defined, in 3.2.2.3,
as "an integral constant expression with the value 0, or such an expression
cast to type `void *'".

>5-  I disagree with Diomidis Spinellis's opinion a C implementor should
>    go to lengths to punish people for writing bad code. On the contrary,
>    it is in the `Spirit of C' to not break existing code...

Moreover, it is of considerable practical importance.  The benefit of
implementing a compiler for a standard language, rather than one of your
own design, is being able to compile programs written by other people.
I personally would have been pleased to see the "goto" statement left out
of C as unnecessary and trouble-prone, but given that it *is* in the
language, I do *not* want to see it removed from the C compilers I use.
This would unnecessarily break too much (ugly) code, code that does work
and that I don't want to have to fix just now.  Tolerance is a necessity
for a practical compiler.
-- 
A bit of tolerance is worth a  |     Henry Spencer at U of Toronto Zoology
megabyte of flaming.           | uunet!attcan!utzoo!henry henry@zoo.toronto.edu
