C++ Logo

SG12

Advanced search

Subject: Re: [ub] C provenance semantics proposal
From: David Vandevoorde (daveed_at_[hidden])
Date: 2019-04-10 17:35:56


> On Apr 10, 2019, at 6:28 PM, Jens Maurer <Jens.Maurer_at_[hidden]> wrote:
>
> On 11/04/2019 00.06, Jens Gustedt wrote:
>> Hello Jens,
>>
>> On Wed, 10 Apr 2019 23:40:37 +0200 Jens Maurer <Jens.Maurer_at_[hidden]>
>> wrote:
>>
>>>> Inter-object equality comparison has to be supported,
>>>
>>> "Supported" in the sense of "getting a well-defined, stable answer",
>>> I presume. Why do you need that?
>>
>> Because this is all that pointer equality is about. I have to be able
>> to compare pointers to whatever objects for equality. If I can only
>> use it for pointers for which I know that they point to the same
>> object, I don't a need a `==` operator in the language :)
>
> Not quite. It does make sense to compare pointers to subobjects
> within the same larger object, e.g.
>
> int a[100];
> bool b = &a[5] == &a[6];
>
> where, of course, the pointers may come from more involved
> pointer arithmetic.
> This is supported and well-defined in the status quo, I presume,
> and nobody is suggesting to change that.
>
> So, there is a use and need for == on pointers even if you can't
> compare pointers to arbitrary objects.
>
> So, again, why do you need to compare pointers to arbitrary
> objects?

For hash tables where the keys are pointers to objects?

        Daveed


SG12 list run by herb.sutter at gmail.com