On 2020-02-25 02:12, Mouse wrote:
Oh. And I actually do not believe it has to be a constant.
You are correct; it does not need to be a simple constant.
The text says "integer constant expression with the value 0, or such
an expression..."
Yes. (void *)(1-1) is a valid null pointer constant. So, on an
all-ASCII system, is (0x1f+(3*5)-'.'). But, in the presence of
int one(void) { return(1); }
then (one()-one()) is not - it is an integer expression with value
zero, but it is not an integer _constant_ expression. It's entirely
possible that (int *)(one()-one()) will produce a different pointer
from (int *)(1-1) - the latter is a null pointer; the former might or
might not be, depending on the implementation.
As you say, it's an integer expression. And I read that "or" part as
just an expression, which this is. So I believe it is a valid way to
creating something that can be converted to a NULL pointer.
Also:
if (expression) statement; shall execute statement if expression not
equals 0, according to the standard.
So, where does that leave this code:
char *p;
.
.
if (p) foo();
p is not an integer. How do you compare it to 0?
Johnny
--
Johnny Billquist || "I'm on a bus
|| on a psychedelic trip
email: b...@softjar.se || Reading murder books
pdp is alive! || tryin' to stay hip" - B. Idol