C++ Logo


Advanced search

Re: [ub] Justification for < not being a total order on pointers?

From: Lawrence Crowl <Lawrence_at_[hidden]>
Date: Thu, 10 Oct 2013 00:36:18 -0700
On 10/9/13, Jens Maurer <Jens.Maurer_at_[hidden]> wrote:
> On 10/10/2013 08:21 AM, Lawrence Crowl wrote:
>> The total ordering can be significantly more complex than today whenever
>> two segments can refer to the same memory. In general, it may require
>> an OS query to the virtual table to provide the ordering, which is likely
>> to be way more expensive than anyone would like.
> Why should < reflect such virtual memory hackery at all?
> Note that comparing pointers to different complete objects yields
> unspecified results anyway (see 5.9 expr.rel).
> I don't think there is a way to tell C++ that I've got two pointers
> that look like pointing to different objects (= different regions of
> storage), yet are the same when looking through the VM layers.
> Such a setup should cause all kinds of aliasing issues, where < is the
> least of the problems.

The problem is that if you need to represent an object with more than
one segment (as was necessary for arrays > 64 kB on x86) then
requiring a total order within an array places a consistency requirement
on computing a total order between arrays.

We could effectively require all objects to be represented by a single
segment, but we should be clear that we are doing so.

Lawrence Crowl

Received on 2013-10-10 09:36:22