Newsgroups: comp.lang.c Path: utzoo!henry From: henry@utzoo.uucp (Henry Spencer) Subject: Re: Uninitialized externals and statics Message-ID: <1989Aug25.185428.3511@utzoo.uucp> Organization: U of Toronto Zoology References: <2128@infmx.UUCP> <4700042@m.cs.uiuc.edu> Date: Fri, 25 Aug 89 18:54:28 GMT In article <4700042@m.cs.uiuc.edu> kenny@m.cs.uiuc.edu writes: >... When a pointer is compared with an integer, it is >implicitly promoted to an integer. Saying > if (foo == NULL) >means EXACTLY the same thing as saying > if (foo == (char *) NULL) >and if the NULL pointer doesn't have an all-zero representation, the >compiler is responsible for promoting it... Right conclusion, seriously wrong reasons. Comparing a pointer to an integer is *illegal* in general. There is one, repeat one, special case: an integer constant expression of value zero -- repeat, an integer CONSTANT expression of value ZERO -- gets turned into a NULL pointer of the appropriate type when compared to a pointer. Note that it is the integer, not the pointer, that is converted. Note that no such conversion is done on integer variables, integer constant expressions with non-zero values, or general integer expressions. -- V7 /bin/mail source: 554 lines.| Henry Spencer at U of Toronto Zoology 1989 X.400 specs: 2200+ pages. | uunet!attcan!utzoo!henry henry@zoo.toronto.edu