Uninitialized externals and statics
Henry Spencer
henry at utzoo.uucp
Sat Aug 26 04:54:28 AEST 1989
In article <4700042 at m.cs.uiuc.edu> kenny at 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 at zoo.toronto.edu
More information about the Comp.lang.c
mailing list