Better HN
topnewbestaskshowjobs
Log inSign up

aCthrowa

4 karma · joined Aug 18, 2015 (11y ago) · 3 submissions

Submissions

comment 11y ago · link · parent

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.

comment 11y ago · link · parent

ptrdiff_t is the wrong type for exactly this reason. OP's article is... not good.

comment 11y ago · link · parent

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.