Using NULL as an illegal pointer

chris at umcp-cs.UUCP chris at umcp-cs.UUCP
Mon Jul 2 14:14:09 AEST 1984


You can argue the merits of ``char *foo = NULL;'' versus ``char
*foo = (char *)NULL;'' 'til you're blue in the face, but the C
language specification requires that assignments (and return values)
be of the same type as the left hand side of the assignment (or
the type of the function).  If a C compiler generate different code
for

	char *func() { return 0; }

and

	char *func() { return (char *) 0; }

then it is broken.
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci (301) 454-7690
UUCP:	{seismo,allegra,brl-bmd}!umcp-cs!chris
CSNet:	chris at umcp-cs		ARPA:	chris at maryland



More information about the Comp.lang.c mailing list