C++ Logo

std-proposals

Advanced search

Re: What happened on "Null safety" in p0946r0 about p <=> nullptr

From: Arthur O'Dwyer <arthur.j.odwyer_at_[hidden]>
Date: Thu, 5 Dec 2019 08:16:43 -0500
On Thu, Dec 5, 2019, 6:13 AM Jake Arkinstall via Std-Proposals <
std-proposals_at_[hidden]> wrote:

> Ah of course. I'm thinking of a comparison that demands two identical
> argument types, which isn't necessarily the case.
>
> Im just thinking from the memory model point of view. A nullptr is
> implicitly convertible to a fictional object at address 0. Valid pointers
> represent objects at address >0.
>

...or <0. I don't know what the default is these days, but I remember that
Intel x86 at least *used* to have signed pointers. That is,
(char*)0xffffffff would compare less than (char*)0x00000001, exactly the
same way that (int)0xffffffff compares less than (int)0x00000001.

I think it would be good to require pointer comparison to be a total order
consistent with std::less, but there is clearly a lot of influence on the
opposite side, or else the wording for std::less wouldn't be so complicated.

https://quuxplusone.github.io/blog/2019/01/20/std-less-nightmare/

Arthur

Received on 2019-12-05 07:19:19