Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!sdd.hp.com!ucsd!pacbell.com!pacbell!barn!everexn!roger From: roger@everexn.uucp (Roger House) Newsgroups: comp.lang.c Subject: Re: What C compilers have non-zero null pointers? Message-ID: <1990Jul11.030758.5450@everexn.uucp> Date: 11 Jul 90 03:07:58 GMT References: <422@minya.UUCP> Organization: Everex Systems, Inc. Lines: 33 In <422@minya.UUCP> jc@minya.UUCP (John Chambers) writes: > ... "The assignment is a pure copy >operation, with no conversion." This means that in: > int i; > char*p; > i = 0; > p = i; >the value assigned to p is the same bit pattern as i (which needs >to be long on some machines, of course). ... I don't know about the Bible, but the ANSI C standard does NOT say that p = i is a pure copy. Page 37 of the standard Rationale says: Since pointers and integers are now considered incommensurate, the only integer that can be safely converted to a pointer is the constant 0. The result of converting any other integer to a pointer is machine dependent. Also, p38 of the standard itself says: An integral constant expression with the value 0, or such an expression cast to type void *, is called a null pointer con- stant. If a null pointer constant is assigned to or compared for equality to a pointer, the constant is converted to a pointer of that type. Such a pointer, called a null pointer, is guaranteed to compare unequal to a pointer to any object or function. Note the term "integral constant expression". In your example, i is not a constant expression, so the result of p = i is machine dependent. Roger House