[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: NULL pointers.

From: Daniel Berlin <dberlin_at_dberlin.org>
Date: 2003-10-14 05:10:12 CEST

On Oct 13, 2003, at 10:45 PM, Marc Singer wrote:

> On Mon, Oct 13, 2003 at 10:21:52PM -0400, Daniel Berlin wrote:
>>
>> On Oct 13, 2003, at 9:54 PM, Marc Singer wrote:
>>
>>> On Mon, Oct 13, 2003 at 06:11:08PM -0700, Jack Repenning wrote:
>>>>> Sooooo, a simple way of being sure that your memory is initialized
>>>>> properly, even on systems where a null pointer constant is not
>>>>> all-zero-bits, is this:
>>>>>
>>>>> struct some_complex_struct *foo
>>>>>
>>>>> {
>>>>> struct some_complex_struct __tmp = { 0 };
>>>>
>>>> Doesn't this fail for the case where the _first_ field of
>>>> some_complex_struct is a pointer, and the local architecture does
>>>> something inane with NULL?
>>>
>>> Is there an architecture that doesn't use ((void*) 0) for NULL?
>>
>>
>> That would violate the C99 standard.

> I have to assume you mean the (void *) part which isn't the point.

No, i don't:

"An integer constant expression with the value 0, or such an expression
cast to type void *, iscalled anull pointer constant. 55) If a null
pointer constant is converted to a pointer type, the resulting pointer,
called anull pointer, isguaranteed to compare unequal to a pointer to
anyobject or function. "

an integer constant expression with the value 0 by itself is the null
pointer constant. period. Nothing else is.
Converted to any pointer, it's the null pointer.

Further, given that, "Conversion of a null pointer to another pointer
type yields a null pointer of that type. Any two null pointers shall
compare equal.",
then even if you could find a wacky way to come up with a non-zero null
pointer, it would have to compare equal to the 0 based null pointer.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Tue Oct 14 05:10:50 2003

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.