Date: Fri, 25 Jul 2025 11:24:21 -0700
> Which has never happened. Never ever.
Except it has happened, but even if it hadn't C++ clearly does not require
that nullptr have bit pattern 0 so it doesn't really matter. It could
happen, unless we changed the requirement.
On Fri, 25 Jul 2025 at 10:32, Frederick Virchanza Gotham via Std-Proposals <
std-proposals_at_[hidden]> wrote:
>
>
> On Friday, July 25, 2025, Julien Villemure-Fréchette wrote:
>
>>
>> Even the following is unspecified (could be true or false)
>> "(void*)nullptr != reinterpret_cast<void*>(0x0)"
>>
>
>
>
> I think you're suggesting it might be false if a nullptr is represented in
> memory by all bits 1.
>
> Which has never happened. Never ever.
>
> I'm not even talking just about C and C++. No programming language has
> ever represented a null pointer with anything other than all bits zero.
>
> That's why I 'memset(p,0,sizeof p)' for arrays of pointers.
>
> It could be a fun project though to start editing the g++ source code so
> that nullptr is all bits 1. Actually I think I'd use such a compiler as a
> debugging tool. I would build my program normally with an
> all-bits-zero-nullptr compiler, test it and then a second time build it
> again with an all-bits-one-nullptr compiler and test it again. If it runs
> successfully with the former but crashes with latter, it might mean that
> I'm accessing a page of memory before I've written to it (i.e.
> uninitialised memory reading as zero).
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>
Except it has happened, but even if it hadn't C++ clearly does not require
that nullptr have bit pattern 0 so it doesn't really matter. It could
happen, unless we changed the requirement.
On Fri, 25 Jul 2025 at 10:32, Frederick Virchanza Gotham via Std-Proposals <
std-proposals_at_[hidden]> wrote:
>
>
> On Friday, July 25, 2025, Julien Villemure-Fréchette wrote:
>
>>
>> Even the following is unspecified (could be true or false)
>> "(void*)nullptr != reinterpret_cast<void*>(0x0)"
>>
>
>
>
> I think you're suggesting it might be false if a nullptr is represented in
> memory by all bits 1.
>
> Which has never happened. Never ever.
>
> I'm not even talking just about C and C++. No programming language has
> ever represented a null pointer with anything other than all bits zero.
>
> That's why I 'memset(p,0,sizeof p)' for arrays of pointers.
>
> It could be a fun project though to start editing the g++ source code so
> that nullptr is all bits 1. Actually I think I'd use such a compiler as a
> debugging tool. I would build my program normally with an
> all-bits-zero-nullptr compiler, test it and then a second time build it
> again with an all-bits-one-nullptr compiler and test it again. If it runs
> successfully with the former but crashes with latter, it might mean that
> I'm accessing a page of memory before I've written to it (i.e.
> uninitialised memory reading as zero).
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>
Received on 2025-07-25 18:24:38