I have a few misunderstanding (or points of hesitations) about size_t and intptr_t
as far as I know intptr_t guarantees some pointer difference might fit that type, and size_t is the range type of sizeof . In a setup where I have a memory of 2^128 bytes, could size_t and intptr_t be only defined on 64 bits?
that would be a good scenario because from the inside of C, I guess I won't be able to create a piece of data for a number larger than 2^64, so chill. But if I do allocate 2^64 bytes in a char array for example, it means the difference between the start and the end would exceed intptr_t capacity. This is fine a per the spec: intptr_t is not mandated to represent every pointer difference.
Now in a scenario where the memory is only 2^53 bytes for example, and both intptr_t and size_t are on 64 bits, then I see that I can fairly represent every data size as a size_t and once I allocated a char[] for example, I can subtract the start and the end and get a validintptr_t. However, the converse is now false: not every intptr_t represents a valid pointer difference. Given a start char* p and a diff intptr_t d, I don't have p+d guaranteed to point somewhere legal
is everything here already correct?
Are there existing properties (from the spec, C99) that allows for some interplay between size_t and intptr_t , or uintptr_t ? Because as far as I understand right now, those two types seem to be fairly independent and not a lot can be said to go from one to another