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).