Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10 5/3/83; site bbncca.ARPA Path: utzoo!linus!bbncca!keesan From: keesan@bbncca.ARPA (Morris Keesan) Newsgroups: net.lang.c Subject: Re: offsets in structures. Message-ID: <1013@bbncca.ARPA> Date: Fri, 12-Oct-84 18:34:00 EDT Article-I.D.: bbncca.1013 Posted: Fri Oct 12 18:34:00 1984 Date-Received: Sat, 13-Oct-84 02:16:02 EDT References: <185@rlgvax.UUCP> Organization: Bolt, Beranek and Newman, Cambridge, Ma. Lines: 18 >That's a broken compiler. "(struct foo *)0" is of type "pointer to 'struct >foo'", so adding 1 to it should make it point to the "next" object of type >"struct foo". > > Guy Harris > As John Bruner has already pointed out, this is not at all broken behavior on the part of the compiler. Section 7.14 of the C Reference Manual (p. 192 in K&R) says, " . . . it is guaranteed that assignment of the constant 0 to a pointer will produce a null pointer distinguishable from a pointer to any object." This means that although "(struct foo *)0" is indeed of type "pointer to 'struct foo'", it is guaranteed not to point to any object, so it is meaningless to refer to the "next" object. -- Morris M. Keesan {decvax,linus,ihnp4,wivax,wjh12,ima}!bbncca!keesan keesan @ BBN-UNIX.ARPA