2
$\begingroup$

I read here that the reason that intptr_t and uintptr_t are optional in C is because there might be a platform where pointers are much bigger than any built-in integer type. They specifically cite some platforms with 128-bit pointers.

However a 128-bit pointer seems a pointless (no pun intended) waste as a 64-bit pointer already has enough possible values to accommodate 18 quintillion bytes (18 exabytes) of RAM. No computer will realistically have even close to that.

So my question is what is the motivation for having any pointers larger than 64-bits? What can 128-bit pointers do that 64-bit pointers cannot do on any realistic computer?

$\endgroup$

1 Answer 1

4
$\begingroup$

Pointers don't have to be just memory addresses. Pointers with extra information are known as "fat pointers" and have various uses.

A bounds-checked C implementation may use pointers that contain the start and end addresses of the array into which they point. Judging by this comment, the 128-bit pointers on the Elbrus architecture are of that type: they use a 64-bit array start address and a 32-bit size and current position (which limits arrays to 4 GiB).

According to this comment, AS/400 uses fat pointers for capability-based security. The capability attached to a pointer is similar to a segment in x86 protected mode (a feature that was dropped in x64).

$\endgroup$
3
  • $\begingroup$ There seems to be a vague memory of Intel starting development of a successor to x86 other than Itanium that had fat pointers. That was years back so I think it was 64 bit when 32 bit were needed, but the same principle. Also ARM (and possible others) use cryptography to set the highest otherwise unused bits of pointers, say 10 bits, so the processor can detect certain hacking attempts. That would be much more effective with 128 bit pointers - at a cost, obviously. $\endgroup$
    – gnasher729
    Oct 25, 2023 at 13:45
  • $\begingroup$ TL;DR 128 bit pointers give you the benefits of segments with none of the drawbacks. $\endgroup$
    – Pseudonym
    Oct 25, 2023 at 22:53
  • $\begingroup$ @gnasher729 I think you are thinking of the Intel iAPX 432, BiiN and i960 extended architecture – they had capabilities/fat pointers called "access descriptors" – see e.g. righto.com/2023/07/the-complex-history-of-intel-i960-risc.html – although they weren't actually that "fat" (only 32 bits, plus in i960 a 33rd tag bit). For a contemporary example, look at CHERI and ARM Morello – cl.cam.ac.uk/research/security/ctsrd/cheri $\endgroup$ Feb 29 at 6:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.