Xenix286 Wonders, Bugs, and Patches...

alex at ucla-cs.UUCP alex at ucla-cs.UUCP
Sun May 12 13:49:59 AEST 1985


[Yes, Virginia, people do post without thinking!]

In article <10550 at brl-tgr.ARPA> BARNES at TL-20A.ARPA writes:
>In article <2158 at sun.uucp> guy at sun.uucp (Guy Harris) writes:
>>> 	exec() doesn't always work with the large model due to NULL being
>>>	placed at the end of the arg list instead of (char *)NULL.  This is a
>>> 	programmer problem more than a bug...
>
>NULL is usually declared in stdio.h as:
>	#define NULL 0
>Kernighan & Ritchie on page 98 state explicitly that, "In general, integers
>cannot meaningfully be assigned to pointers; zero is a special case."  On the
>previous page they state, "C guarantees that no pointer that validly points at
>data will contain zero, ..."
>
>Thus, the code is not buggy in the least; with or without casting...

Aaaaarrrrrggggghhhhhhhh!  How about net.lang.c.bozo?  

When NULL is passed as a parameter the compiler doesn't necessarily know
that NULL is supposed to be a pointer and should possibly be widened or
otherwise modified.  After all NULL is simply 0; the context surrounding
its use determines whether it is a pointer.  Since functions can be
defined in different files and compiled separately, the formal parameter
declarations for the called function aren't guaranteed to be available
when the function is compiled, and one must explicitly cast the NULL
parameter to a pointer if one wants to write correct code.

The bug, as Guy pointed out, is in the programmer rather than the compiler.
And the bug seems to be amazingly difficult to get rid of.

Alex Quilici     alex at ucla-cs   {ucbvax, ihnp4}!ucla-cs!alex



More information about the Comp.unix.wizards mailing list