Deutsch   English   Français   Italiano  
<v6crt3$1gpa$2@dont-email.me>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!feeds.phibee-telecom.net!news.mixmin.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: James Kuyper <jameskuyper@alumni.caltech.edu>
Newsgroups: comp.lang.c
Subject: Re: question about nullptr
Date: Sat, 6 Jul 2024 21:44:03 -0400
Organization: A noiseless patient Spider
Lines: 29
Message-ID: <v6crt3$1gpa$2@dont-email.me>
References: <v6bavg$3pu5i$1@dont-email.me> <20240706054641.175@kylheku.com>
 <v6bfi1$3qn4u$1@dont-email.me> <l9ciO.7$cr5e.2@fx05.iad>
 <v6c942$3ui41$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 07 Jul 2024 03:44:04 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="8e847e201f1ac6ac487c614b591508d8";
	logging-data="49962"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1/T47xUnVG4QIoVgLa9JxKfVCBGZfRvKp4="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:bcrh5cPTMFm18jRniuTMFqwY45w=
Content-Language: en-US
In-Reply-To: <v6c942$3ui41$1@dont-email.me>
Bytes: 2335

On 7/6/24 4:23 PM, Chris M. Thomasson wrote:
> On 7/6/2024 7:04 AM, Scott Lurndal wrote:
....
>> Whereas I spent 6 years programming on an architecture[*] where a
>> null pointer was represented in hardware by the value 0xc0eeeeee.  I 
>> always
>> use the NULL macro in both C and C++ code.
> 
> Where:
> 
> void* x = 0;
> 
> Should be x = 0xc0eeeeee, right?

No, 0 is a null pointer constant. The C standard requires that when a
null pointer constant is converted to a pointer value, it must be
converted to a null pointer of that type. The result will be that the
representation of 'x' after such an assignment would be 0xc0eeeeee.

Whether or not an integer value of 0xc0eeeeee can be converted to a
pointer type, and what that pointer's value would be after the
conversion is up to the implementation.

Note that even after x acquires that representation, it's still required
to compare equal to 0. For the purposes of the comparison, the null
pointer constant gets converted to a null pointer of the appropriate
type. All null pointers, regardless of representation (the C standard
allows there to be multiple ways of representing null pointers) must
compare equal.