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 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: References: <20240706054641.175@kylheku.com> 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: 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.