Mail Archives: djgpp/2013/08/03/14:02:35
> A NULL is not required to be mapped to low memory. This is
> irrelevant. NULL's actual value is not required to be zero, only
> different.
NULL's actual value is required to be zero, from the program's point
of view.
> (No joke. You can ask even the angry nutjobs on c.l.c and get that
> correct answer. Please read the two posts which I provided links
> to. They're by one of the authors of the ANSI C specifications.)
Sure. The physical address of "0" in a virtual memory system is
rarely itself zero, and some systems use segment/offset or tag/offset
addressing too.
> True. We were discussing how to make a NULL more useful by
> preventing atoi() from failing when passed in. One method is for
> NULL to be not just a "char pointer", but also be "a pointer to a
> string" - an empty string.
IMHO, making "passing NULL" crash your app is more useful, because
then the debugger can tell you exactly where you went wrong. Even the
MCU simulators I write for work have *NULL==crash for debugging.
> Sorry, you've made a logic error here. The prior quote of yours
> only requires the address used for the NULL to be unequal to any
> valid object or function. You've implicitly defined your own term:
> "valid string",
s/string/array of char/ then
arrays are certainly valid objects.
IMHO if a pointer points to *anything* that "works", it's a bad choice
for NULL.
- Raw text -