Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!rutgers!sri-spam!mordor!styx!ptsfa!ihnp4!inuxc!pur-ee!uiucdcs!uiucdcsp!lopez From: lopez@uiucdcsp.cs.uiuc.edu Newsgroups: comp.lang.c Subject: Re: To comment 48: Xenix Message-ID: <77200008@uiucdcsp> Date: Wed, 29-Apr-87 14:25:00 EDT Article-I.D.: uiucdcsp.77200008 Posted: Wed Apr 29 14:25:00 1987 Date-Received: Sat, 2-May-87 10:38:26 EDT References: <77200001@uiucdcsp> Lines: 66 Nf-ID: #R:uiucdcsp:77200001:uiucdcsp:77200008:000:2059 Nf-From: uiucdcsp.cs.uiuc.edu!lopez Apr 29 13:25:00 1987 >/* Written 1:45 pm Apr 27, 1987 by guy%gorodish@Sun.COM in uiucdcsp:comp.lang.c */ >you have some justification for flaming the author(s) of your >compiler. The two constructs are equivalent, and any good compiler >will produce equally efficient code for them. The above is irrelevant since I believed that the null-pointer was equivalent to (int)zero. "apparently not true" Plus I assumed a "dumb" compiler "in this day and age is very common." > > 1) a 32-bit zero value *is* an integer; it just doesn't > happen to be an "int"; True, but irrelevant: (integer was used in terms of the latter, that doesn't need explanation). > > 2) "we" don't need a 32-bit zero value, we need a null > pointer of the appropriate type, and null pointers are not > integers. paraphase: (null pointers internally are not integers) When you enter (charptr == 0) in your "C" source code, when the compiler takes its first pass and sees the zero, it will first identify it as a zero and then see that it is a special case and make the transformation. If I am wrong, tell me. for, page 97 "K&R" "In general, integers cannot meaningfully be assigned to pointers; zero is a special case." ::Quote. By definition zero is an integer. ::Math. Good argument for not having NULL being "0". ::Common Sense. If NULL is not (int)zero, then C should not be using the symbol "0" to represent it and (int)0. ::Statement. :-> but by page 97 it appears that NULL is (int)zero and that it :-> is up to the compiler to take care of the special case. Lastly, p. 192 says: "the assignment of the constant 0 to a pointer will produce a null pointer". Meaning? the pointer now has the value of zero. (or can this be seen as compiler dependent). Can each compiler writer have their own way of representing a NULL pointer (internally). We have two different types (pointers and integers) I seemed to have forgotten that; been writing too many lines of "C" lately. > >/* End of text from uiucdcsp:comp.lang.c */