Subject: Re: __UNCONST(a)
To: der Mouse <mouse@Rodents.Montreal.QC.CA>
From: Greg A. Woods <firstname.lastname@example.org>
Date: 07/05/2004 19:25:09
[ On Thursday, July 1, 2004 at 21:41:52 (-0400), der Mouse wrote: ]
> Subject: Re: __UNCONST(a)
> >>> When subtracting pointers they both have to point into the same
> >>> array.
> >> Isn't it into the same _object_?
> > How can a NULL pointer ever point to the same storage object as any
> > other non-NULL pointer?
> _Into_, not _to_.
Same difference (at least for NULL). ;-)
By definition a null pointer in C points nowhere -- it explicitly points
(in)to no object or function, or in the language of C9x (at least of the
ISO 9899 JTC1/SC22/WG14/N869 committee draft from Jan 18, 1999):
§ 184.108.40.206 ¶3
An integer constant expression with the value 0, or suah an expression
cast to type "void *", is called a "null pointer constant." If a null
pointer constant is converted to a pointer type, the resulting
pointer, called a null pointer, is guaranteed to compare unequal to a
pointer to any object or function.
As far as I can tell there's no one statement in the standard to the
effect that "pointer arithmetic with the NULL pointer is invalid", but I
believe this is effectively true given the restrictions necessary for
non-contiguous memory systems and systems with different representations
for various pointer types. I.e. only comparisons with NULL are valid in
Greg A. Woods
+1 416 218-0098 VE3TCP RoboHack <email@example.com>
Planix, Inc. <firstname.lastname@example.org> Secrets of the Weird <email@example.com>