Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!rutgers!ames!oliveb!sun!gorodish!guy From: guy@gorodish.UUCP Newsgroups: comp.lang.c Subject: Re: Query: Implementation with non-zero NULL Message-ID: <20412@sun.uucp> Date: Fri, 5-Jun-87 03:26:58 EDT Article-I.D.: sun.20412 Posted: Fri Jun 5 03:26:58 1987 Date-Received: Sat, 6-Jun-87 07:19:56 EDT References: <158@delftcc.UUCP> <3673@gitpyr.gatech.EDU> <414@sds.UUCP> Sender: news@sun.uucp Lines: 36 Keywords: C, NULL, portability > I thought the C language guaranteed that there was an integral type > large enough to hold any pointer type. From p. 210 of the Apocrypha > (== Appendix A of K&R :-) > > A pointer may be converted to any of the integral types > large enough to hold it. Whether an int or long is > required is machine dependent. > > Although the word "guarantee" doesn't appear here (as it does elsewhere), > the second sentence seems to disallow the first sentence from being > vacuously true. More importantly, the next paragraph says: An object of integral type may be explicitly converted to a pointer. The mapping always carries an integer converted from a pointer back to the same pointer, but is otherwise machine dependent. which guarantees that the pointer->integer conversion must not discard any bits that are of any significance; i.e., any such bits must not participate in pointer comparisons, and it must be possible to regenerate those bits if necessary. I don't know if these apply to the 48-bit pointers on the Prime or not. Fortunately, the current ANSI C draft withdraws the guarantee extended by K&R; see the discussion in section 3.2.2.3 of the Rationale, where it says "Since pointers and integers are now considered incommensurate, the only integer that can be safely converted to a pointer is the constant 0." (This kind of bit-banging is generally non-portable anyway; if some architecture renders it awkward to provide a C implementation that permits this to be done in the "straightforward" way, some non-standard way can be provided.) Guy Harris {ihnp4, decvax, seismo, decwrl, ...}!sun!guy guy@sun.com