T
Tim Rentsch
Harald van =?UTF-8?b?RMSzaw==?= said:You snipped the actual question, which was to cite a specific clause in
the standard that such an implementation would violate.
Once again, assume the following (I'll change the example a bit):
sizeof (short) == 2
The following:
short *ptr = calloc(SIZE_MAX, sizeof *ptr);
succeeds, causing ptr to point to the first element of an array
object whose size is SIZE_MAX*2 bytes. You can successfully read
and write all SIZE_MAX short objects in the allocated object, from
ptr[0] to ptr[SIZE_MAX-1].
sizeof (short[SIZE_MAX]) is rejected with a diagnostic at compile
time. (I would expect this to happen for any compiler where sizeof
(short) > 1.)
You claim that this hypothetical implementation is non-conforming. What
specific clause of the standard does it violate?
I don't know who posted this first, but fill the memory, call strlen, and
any result it can give renders the implementation nonconforming as
strlen's description has no exception for strings longer than SIZE_MAX
characters.
It doesn't have to be nonconforming; see my response to Eric Sosman.