Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!hplabs!hp-sdd!ncr-sd!se-sd!rns From: rns@se-sd.NCR.COM (Rick Schubert ) Newsgroups: comp.lang.c Subject: Re: Creating pointer with all bits 0 (was: Referencing NULL pointers) Message-ID: <2030@se-sd.NCR.COM> Date: 2 Sep 89 00:56:12 GMT References: <1989Aug31.052756.18524@sq.sq.com> Reply-To: rns@se-sd.UUCP (Rick Schubert (AEP)) Organization: NCR Corporation, SE-San Diego Lines: 25 In article <1989Aug31.052756.18524@sq.sq.com> msb@sq.com (Mark Brader) writes: [Someone suggested:] >> > could you not access memory location 0 by writing: >> > p = 0; /* integer variable that happens to be set to zero */ >> > data = *(int *)p; /* no constant expression in this line */ [To which Mark Brader responded:] > int *p; > memset ((void *) p, 0, sizeof p); > data = *p; >It may as well be repeated for anyone who's coming in late that >the point here is to get a pointer p with all bits zero, for use >on a machine where null pointers have some other pattern of >bits and all-bits-zero is a meaningful pointer. It may as well >also be repeated that the bit pattern (or patterns; they could >depend on the type) of null pointers have nothing to do with the >fact that 0 is a correct way to write a null pointer constant. It may as well also be repeated (or stated, if it was not originally stated (peated?)) that the pointer with a bit pattern of all-bits-zero does not necessarily reference location 0 (and that the pointer to location 0 is not necessarily represented by a bit pattern of all-bits-zero). -- Rick Schubert (rns@se-sd.sandiego.NCR.COM)