Path: csiph.com!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: Tim Rentsch
Newsgroups: comp.lang.c++
Subject: Re: What is the data structure of a NULL?
Date: Fri, 10 Jan 2020 20:56:36 -0800
Organization: A noiseless patient Spider
Lines: 43
Message-ID: <86y2ue381n.fsf@linuxsc.com>
References:
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: reader02.eternal-september.org; posting-host="a658bb27d1b88b897660621da5fe7a9e"; logging-data="25741"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX197AXm/uQdt9NPU5YfsUx+49bh6uenLNFI="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:ASjaLfGVpV6VAcESKEamCD3GA7M= sha1:/PmdZw3ZPDFjfhnYk3GWMSELc9Y=
Xref: csiph.com comp.lang.c++:71273
James Kuyper writes:
> On 12/27/19 4:36 PM, Ian Collins wrote:
>
>> On 28/12/2019 10:24, T wrote:
>>
>>> Hi All,
>>>
>>> In C++, when you make a call to Windows Kernel32.dll
>>> and it wants a NULL for one or more of its parameters,
>>> what exactly is the structure of a NULL? A 32 bit
>>> word full of zeros?
>>
>> The C standard defines a null pointer as
>>
>> "An integer constant expression with the value 0, or such an expression
>> cast to type void *, is called a null pointer constant."
>
> That's the definition of a "null pointer constant". The definition of a
> null pointer comes on the immediately following line:
>
> "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."
> Note that the second occurrence of the phrase "null pointer" in that
> sentence is in italics, an ISO convention indicating that this sentence
> constitutes the official definition of the italicized phrase. In this
> case, it's a little unclear; the first part of that sentence is not
> actually the definition, it's a one of several ways to obtain a null
> pointer (other ways include calling various standard library functions
> that are documented as returning null pointers under certain
> circumstances). It's actually the end of that sentence that defines what
> null pointer is: a pointer guaranteed to compare unequal to a pointer to
> any object or function.
The first part of the sentence is the definition. Other ways of
obtaining a null pointer value therefore must have derived that
value, at some point in the program's history, by converting a
null pointer to some pointer type. The second part of the
sentence gives a property that null pointers must satisfy, but is
not the definition of null pointer. It is perfectly possible to
have a pointer value that compares unequal to a pointer to any
object or function, but is not a null pointer.