C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Standardising 0xdeadbeef for pointers

From: Thiago Macieira <thiago_at_[hidden]>
Date: Thu, 31 Jul 2025 11:02:36 -0700
On Thursday, 31 July 2025 10:23:36 Pacific Daylight Time Sebastian Wittmeier
via Std-Proposals wrote:
> AMD, Intel or ARM could introduce a new ADD function, which automatically
> creates an exception, if the first argument is the nullptr. The compilers
> would use that instruction, whenever pointer arithmetic is done.

While it's highly unlikely that x86 would add such an instruction, other
architectures have had similar things. The Itanium had instruction "addp4"
which added a 32-bit pointer to a 32-bit displacement to produce a 64-bit
pointer. It didn't fault on adding a non-zero displacement to a null pointer,
but that could have been a new feature to the processor, had it continued
being developed.

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
  Principal Engineer - Intel Platform & System Engineering

Received on 2025-07-31 18:02:42