Boost logo

Boost :

Subject: Re: [boost] [uuid] Interface
From: Michael Marcin (mike.marcin_at_[hidden])
Date: 2008-12-29 14:49:36

Vladimir Batov wrote:
>>> the same -- 'm_uuid' initialized invalid -- but explicit about what
>>> it actually does.
>> I realize invalid vs nil/null was discussed earlier but I still don't
>> like using those terms interchangeably.
> I've been wondering where that "invalidity" property of nil/null comes
> from for me? For me it certainly started with K&R stating "The symbolic
> constant NULL is ... to indicate more clearly that this is a special
> value for a pointer." That is, it was not just another but special
> pointer to start with. Then, through many years, that "special" property
> has been firmly ingrained for me as "invalid" due to
> char* p1;
> char* p2 = NULL;
> char* p3 = "mama";
> strlen(p1); // bombs
> strlen(p2); // bombs
> strlen(p3); // good
> For all practical purposes the above makes p1 and p2 quite
> naughty/bad/invalid compared to the well-behaving p3. Despite NULL's
> quite official status in the language(s), strlen() clearly "thinks" that
> NULL is anything but valid and bombs spectacularly. Then, I habitually
> extended that notion onto any foo::null() and ultimately to uuid::nil().

Sorry for the late response. I disagree that NULL is invalid. Reading or
comparing against the value of a NULL pointer is valid but not so
against an uninitialized pointer. There are functions other than strlen
where NULL does not bomb but has a well defined meaning and purpose,
like strtok.

FWIW uninitialized seems to be considered singular by the standard


After the declaration of an uninitialized pointer x (as with int* x;), x
must always be assumed to have a
singular value of a pointer. ]

Michael Marcin

Boost list run by bdawes at, gregod at, cpdaniel at, john at