英文:
Why does the C23 standard decrease the max size of an object the implementation must support?
问题
我目前正在阅读C23标准的新草案(N3088),我注意到在§5.2.4.1中,标准规定:
实现必须能够翻译和执行使用以下限制的程序,但不得超过这些结构和实体的限制:... 在托管环境中,对象的字节数不得超过32767字节。
这个数字是ANSI C/C89中的数字,自从C99以来已经提高到65535字节 - 降低回原始数量的原因是什么?
我尝试在这里和WG 14文件日志中查找相关信息,但没有找到任何内容。
英文:
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
得分: 9
更改已被还原,以便ptrdiff_t
,必须是有符号的,只能有16位宽度,同时仍然表示实现中所有对象的开始和结束之间的字节差异,特别是嵌入式对象。根据这些要求,实现中的对象不能大于32767字节。
请参阅提案N2808,以及N2883中的C/C++兼容性讨论。
英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论