News for hackers. Stuff that matters.

aCthrowa

Re:About size_t and ptrdiff_t on Tuesday August 18, 2015 @01:28PM (#10080642)
Yes, this limits the utility of ptrdiff_t. But I don't believe you're allowed to subtract arbitrary pointers in C anyway. So you might need a >63-bit char array in order to legally hit this limit, and you probably don't have 263 of RAM.

Practically, amd64 is already limited to more like 48 bits (4 levels of 9 bit pagetables describing 12 bit pages) of memory.

Re:About size_t and ptrdiff_t on Tuesday August 18, 2015 @01:25PM (#10080606)
ptrdiff_t is the wrong type for exactly this reason. OP's article is... not good.
Re:About size_t and ptrdiff_t on Tuesday August 18, 2015 @01:24PM (#10080601)
This may be practically correct, but is semantically very very wrong.

size_t represents the size of objects in memory. So of course it scales with virtual memory space.

ssize_t is like size_t (same width), but signed. It's useful for routines that want to return a size_t or error (network routines like send/recv).

ptrdiff_t is specifically for the result of subtracting one pointer from another. Obviously it scales with pointer size as well.