Date: Tue, 21 Jul 2020 09:14:23 -0700
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
OS).
But I digress.
> 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
OS).
But I digress.
-- Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org Software Architect - Intel DPG Cloud Engineering
Received on 2020-07-21 11:17:45