Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!husc6!think!ames!oliveb!sun!gorodish!guy From: guy%gorodish@Sun.COM (Guy Harris) Newsgroups: comp.lang.c Subject: Re: Query: Implementation with non-zero NULL Message-ID: <20130@sun.uucp> Date: Mon, 1-Jun-87 17:49:58 EDT Article-I.D.: sun.20130 Posted: Mon Jun 1 17:49:58 1987 Date-Received: Wed, 3-Jun-87 02:26:49 EDT References: <158@delftcc.UUCP> <3673@gitpyr.gatech.EDU> Sender: news@sun.uucp Lines: 57 Keywords: C, NULL, portability Summary: If that's true, then PRIME didn't implement C > On the PRIME system under PRIMIX, there is a special "undefined pointer" > value. This value is used by the procedure call mechanism when fewer > arguments are passed to a subroutine by reference (ie FORTRAN) than > are expected. Because of this, constructs such as the > > if(p) > > Do not yield correct results. Translation: PRIME has no implementation of C on their machines. If the construct if (p) where "p" is a pointer does not compare "p" with the undefined pointer value, then the language being implemented isn't C. Furthermore, the clauses if (p) if (p != NULL) if (p != 0) if (p != (whatever_p_points_to *)0) if (p != (whatever_p_points_to *)NULL) all have the same meaning in C, so they must all compile to equivalent code. It may seem counter-intuitive that the statement if (p) compare the bit pattern stored in "p" with a bit pattern other than all-zeroes, but that's just too bad - that's the way C works. One would hope any C implementor would be sufficiently aware of the way C works to avoid naively generating a test against 0 for this construct; if, in fact, the PRIME C compiler does generate such a test, I guess there are C implementors out there too naive to properly implement C. Are you certain that that construct doesn't yield a correct result (e.g., compares "p" with an all-zero bit pattern), or are you just assuming this? > The value of NULL is 0x60000000 on a prime. If you mean that things like contain #define NULL 0x60000000 then this confirms that they didn't implement C. Guy Harris {ihnp4, decvax, seismo, decwrl, ...}!sun!guy guy@sun.com