Subject: Re: __UNCONST(a)
To: NetBSD Userlevel Technical Discussion List <tech-userlevel@NetBSD.ORG>
From: der Mouse <mouse@Rodents.Montreal.QC.CA>
Date: 07/05/2004 20:58:35
>>> 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). ;-)
True. I misread the question as asking, basically, how different
pointers can point into the same object - reinforced by the "other", I
misread the first NULL as non-NULL.
> 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",
I think it follows because pointer arithmetic is valid only when you
stay within (or just beyond) the object the pointer started out
pointing into. Since a null pointer does not point into any object, no
arithmetic on it can be valid.
Nevertheless, like a lot of other strictly nonportable hacks, the trick
given is a cool and useful hack.
/~\ The ASCII der Mouse
\ / Ribbon Campaign
X Against HTML firstname.lastname@example.org
/ \ Email! 7D C8 61 52 5D E7 2D 39 4E F1 31 3E E8 B3 27 4B