Need some examples

Craig Partridge craig at LOKI.ARPA
Wed Jul 31 03:24:29 AEST 1985


    I know this general subject has been hashed over before so please
respond to me directly, not to the whole net.  If I get enough
requests I'll post a summary.

    There are a variety of funny little problems with using the 0
pointer in C.  Recently I have gotten into a debate with a friend
about passing a 0 pointer to a function.  We agree that given
a function declaration like

f(ptr)
foo *ptr;
{
	[code]
}

calling f(0) is dangerous.  But my friend contends that calling
f() with a zero char pointer, e.g. f((char *)0), is safe, because
(char *) is the largest pointer, and that he doesn't know of a C
implementation that doesn't pass all pointers as the largest
possible pointer (ala the way floats always get passed as doubles).
I suspect the argument is wrong (and dangerous), but don't have
examples of machines on which this trick fails.  Anybody got
ammunition out there to help my side out?  (The question is not
just academic, it will affect a C standards document for a project).

Thanks,

Craig Partridge
craig at bbn-loki (ARPA)
craig%loki.arpa at csnet-relay (CSNET)
{decvax,ihnp4,wjh12}!bbncca!craig (USENET)



More information about the Comp.lang.c mailing list