Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!rutgers!lll-lcc!unisoft!hoptoad!academ!killer!jfh From: jfh@killer.UUCP Newsgroups: comp.lang.c Subject: Re: Query: Implementation with non-zero NULL Message-ID: <952@killer.UUCP> Date: Mon, 1-Jun-87 11:22:15 EDT Article-I.D.: killer.952 Posted: Mon Jun 1 11:22:15 1987 Date-Received: Sun, 7-Jun-87 18:39:29 EDT References: <1217@batcomputer.tn.cornell.edu> Organization: The Unix(tm) Connection, Dallas, Texas Lines: 72 Summary: Wrong on several accounts In article <1217@batcomputer.tn.cornell.edu>, garry@batcomputer.tn.cornell.edu (Garry Wiegand) writes: > In a recent article henry@delftcc.UUCP (Henry Rabinowitz) wrote: > >I'm writing a book on C portability. Interested to find actual > >implementation of C where the null pointer is not "all bits zero." > > And I'd be interested in knowing what difference it could ever make > to a portable program: the only ways I know to look at the bits > is to union the pointer with an integer (and load the pointer & > look at the integer), or to cast the pointer to an integer. Both of which > would be very forbidden in portable code. I don't know, I find myself looking at bits from time to time and not even realizing that I am doing myself in, ANSI Standard-wise. As far as forbidding casting a pointer to an integer in portable code, I would think that only the programmer must justify whether or not the cast is needed. Casts are permitted, I think your statement should be 'Both of which should be explicitly declared and well documented.' > >Are static pointers initialized to all bits zero or to the null value > >(as in ANSI spec)? > > You should NEVER assume a not-explicitly-initialized static variable > is given any particular value by anybody. ( low burner on - :-) And you should read some of the documentation on the language. I'm not sure who wrote this version of the C Language reference, but I have seen it included in other vendors manuals. In the Plexus Sys5 Unix Programmer's Guide, section 2.7.7 it says (and I quote) "Static and external variables that are not initialized are guaranteed to start off at zero. Automatic and register variables that are not initialized are guaranteed to start off as garbage." I have seen this before in papers written by the Gods Of Unix ... Sounds like you been usin' too much Pascal ... :-) :-) :-) ( low burner off - :-) > Note: I have not yet seen a compiler written to the ANSI spec. Talking > about porting between ANSI-spec compilers is not a very interesting > thing to do, and won't be for a while (five years, maybe?) Well, of course not. They haven't figured the darn thing out yet. But, not writing to the ANSI spec is going to give you alot of work to do when your vendor sends out the new ANSI compiler and all your programs don't conform. > > >In such an implementation, can you use the conventional abbreviation > > if (p) > >to mean > > if (p != NULL) > > Um, might I suggest that this book project is not really a good idea for > you? And the world? (Please see K&R on the meaning of 'if(p)'). > > garry wiegand (garry@oak.cadif.cornell.edu - ARPA) > (garry@crnlthry - BITNET) Um, Garry, might I suggest that he asked a good question and that you get a personality. Yes, I think the statements if (p) and if (p != NULL) /* where NULL is not (char *) 0 */ could cause us all alot of trouble. - John. Disclaimer - No disclaimer. Whatcha gonna do, sue me?