Firstly, what you quoted from the standard does not make any references to type int
specifically. And no, int
is not guaranteed to be sufficient to store the size of any object (including arrays) in C.
Secondly, C language does not really have "array subscriptions" specifically. The array subscription is implemented through pointer arithmetic. And the integral operand in pointer arithmetics has ptrdiff_t
type. Not size_t
, not int
, but ptrdiff_t
. It is a signed type, BTW, meaning that the value can be negative.
Thirdly, the purpose of size_t
is to store the size of any object in the program (i.e. to store the result of sizeof
). It is not immediately intended to be used as an array index. It just happens to work as an array index since it is guaranteed that it is always large enough to index any array. However, from an abstract point of view, "array" is a specific kind of "container" and there are other kinds of containers out there (lists-based ones, tree-based ones and so on). In generic case size_t
is not sufficient to store the size of any container, which in generic case makes it a questionable choice for array indexing as well. (strlen
, on the other hand, is a function that works with arrays specifically, which makes size_t
appropriate there.)