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:59:17 -0700
On Thursday, 31 July 2025 11:16:40 Pacific Daylight Time Sebastian Wittmeier
via Std-Proposals wrote:
> But if you assign a 0 to a pointer, it has to be converted to NULL.

Which leads to the interesting case where assigning a 0 causes the compiler to
emit a non-zero value. As in

struct S {};
int S:: *f()
{
    return 0;
}

https://gcc.godbolt.org/z/zxTh6ervn

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

Received on 2025-07-31 18:59:22