Must a NULL pointer be a 0 bit pattern?

Henry Spencer henry at utzoo.UUCP
Thu Oct 18 01:57:31 AEST 1984


> 	union {
> 		char *	p_member;
> 		double	f_member;
> 		char	c_member[COVERS_P_AND_F];
> 	} implicitly_initialized_to_zero;
> 
> It seems to me that K&R guarantees that, when the program begins
> execution, p_member, f_member and c_member are guaranteed to be
> zero simultaneously, and the only way to do it is to make them all a
> zero bit pattern.  I don't have my manual with me--can anyone try to
> poke holes in this?  It may be that the K&R wording isn't rigorous
> enough, and that my proof "falls to the ground".

I think your last conjecture is correct, i.e. K&R simply is not being
specific enough.  Note that a floating-point zero isn't necessarily
an all-zeros bit pattern either.  The K&R wording can be interpreted
in one of two ways:

1. Implicitly-initialized storage starts out as all-zeros bit patterns,
	which doesn't necessarily look like a 0 in all data types.

2. Implicitly-initialized storage looks like 0's, and the semantics of
	initializing unions simply aren't defined well enough.
-- 
				Henry Spencer @ U of Toronto Zoology
				{allegra,ihnp4,linus,decvax}!utzoo!henry



More information about the Comp.lang.c mailing list