3 ms·
`size_t` is defined as > the unsigned integer type of the result of the sizeof operator (https://port70.net/~nsz/c/c11/n1570.html#7.19p2 https://port70.net/~ns
by camel-cdr 4y ago
`size_t` is defined as
> the unsigned integer type of the result of the sizeof operator (https://port70.net/~nsz/c/c11/n1570.html#7.19p2 https://port70.net/~nsz/c/c11/n1570.html#7.19p2)
`sizeof` returns the following:
> If the type of the operand is a variable length array type, the operand is evaluated; otherwise, the operand is not evaluated and the result is an integer constant. (https://port70.net/~nsz/c/c11/n1570.html#6.5.3.4p2 https://port70.net/~nsz/c/c11/n1570.html#6.5.3.4p2)
So `sizeof(size_t)` must be a concrete integer constant for any given C implementation, it can't change at runtime.
As far as I'm aware, there isn't an instance of an infinitely large integer, even in mathematics, there are finite integers and there is the concept of infinity.
- lelanthran 4y ago> So `sizeof(size_t)` must be a concrete integer constant for any given C implementation, it can't change at runtime. I didn't say it has to change at runtime, I said that there is no upper limit on it in theory, because the upper limit is specified in terms of the implementation, and a a theoretical implementation with no upper limit on memory means that there is no upper limit on size_t. Besides, I also said: > Sure, size_t is finite in practice, but then again, so are all other programming languages. Using your definition of Turing complete (no upper limit on pointer, references or addresses), I cannot think of one popular language that would satisfy that definition. Can you?
- camel-cdr 4y agoThe easiest example would be brainfuck, which doesn't have addresses and you just move the tape head. I'm not that versed in how other languages are defined, but does e.g. JavaScript even expose pointers to the user? From my understanding of the language, an implementation could be able to allocate infinitely many objects, without breaking the language spec.