Why does the C23 standard decrease the max size of an object the implementation must support?

253 Views Asked by At

I'm currently reading the new draft of the C23 standard (N3088), and I've noticed that in §5.2.4.1 the standard states:

The implementation shall be able to translate and execute a program that uses but does not exceed the following limitations for these constructs and entities: ... 32767 bytes in an object (in a hosted environment only)

This was the number in ANSI C/C89, and since C99 it was raised to 65535 - what is the reason to lower it back to the original amount?

I tried to look for any reference to it here and in the WG 14 Document Log but didn't find anything.

1

There are 1 best solutions below

1
On BEST ANSWER

The change was reverted so that ptrdiff_t, which has to be signed, can be only 16bit wide, while still representing the byte difference between the beginning and end of all objects in an implementation, especially embedded ones. With these requirements objects in the implementation mustn't be larger than 32767 bytes.

See the proposal N2808 and also C/C++ compatibility discussion in N2883.