"the integer constant zero"

der Mouse mouse at mcgill-vision.UUCP
Fri Apr 8 18:26:17 AEST 1988


In article <10754 at mimsy.UUCP>, chris at mimsy.UUCP (Chris Torek) writes:
> [	char *p; p = (0, 0); ]
> [...] the integer constant `0' in a pointer context [...].  What is
> `the integer constant 0'?  Clearly this is any constant expression
> whose value is zero and whose type is one of the integral types
> {char, short, int, long} or their signed or unsigned variants.

"the integer constant zero" is not necessarily the same as "an integer
constant expression zero".

It seems to me that the phrase could reasonably be taken to indicate
that only `0', standing alone, was sufficient.  I think I could make a
case that even putting parentheses around it would break it.

Does dpANS specify exactly what they mean by "the integer constant
zero"?  For example, p=0; assigns a nil pointer to p (assuming a
pointer type for p).  Does the draft make it clear whether p=0+0; also
does?  The RHS is a constant expression with value zero, but this is
not necessarily the same thing as "the [note definite article] integer
constant zero".

Now, how about

#define FIRST 0
char foo[10];  char *p;
p = &foo[FIRST] - &foo[0]; /* now waiiiit a minute.... */

That's constant expression whose value is a zero integer, isn't it?  Is
this wrong or just questionable style?

					der Mouse

			uucp: mouse at mcgill-vision.uucp
			arpa: mouse at larry.mcrcim.mcgill.edu



More information about the Comp.lang.c mailing list