C++ Logo


Advanced search

Subject: Re: [std-proposals] P1839 and the object representation of subobjects
From: Thiago Macieira (thiago_at_[hidden])
Date: 2020-07-21 11:14:23

On Tuesday, 21 July 2020 08:55:45 PDT Thiago Macieira via Std-Proposals wrote:
> Given that uintptr_t must be able to hold the value of any pointer, it too
> must have size 8 bytes (note how sizeof(uintptr_t) > sizeof(size_t))

Hmm... the size_t note rests on an assumption that is not proven. In this
machine, it's clear that sizeof(uintptr_t) > sizeof(ptrdiff_t) by design. But
there's no requirement that objects be limited to 64 GB in size. If they are
allowed to be bigger, then sizeof(size_t) == sizeof(uintptr_t) and both are
bigger than ptrdiff_t.

Still, note that because of pointer limitations, a std::vector could not hold
more than PTRDIFF_MAX-1 elements of any type. A non-contiguous container could
hold more than that, if it has less than 3 bytes of overhead per element. The
only one I can think of is std::deque<char>, which is also the only one that
can do more than PTRDIFF_MAX-1 on regular machines (32-bit process on a 64-bit

But I digress.

Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel DPG Cloud Engineering

STD-PROPOSALS list run by std-proposals-owner@lists.isocpp.org

Standard Proposals Archives on Google Groups