Tag: 标准尺寸

C标准malloc’ing字符的潜在问题

当我在这里回答对我的另一个答案的评论时,我发现我认为可能是C标准中的一个漏洞(c1x,我没有检查过早期的那些,是的,我知道我不可能单独在所有星球中居民在标准中发现了一个错误)。 信息如下: 第6.5.3.4节(“sizeof运算符”)第2节规定”The sizeof operator yields the size (in bytes) of its operand” 。 该部分的第3段指出: “When applied to an operand that has type char, unsigned char, or signed char, (or a qualified version thereof) the result is 1” 。 第7.20.3.3节描述了void *malloc(size_t sz)但它说的是”The malloc function allocates space for an object whose size is specified by size […]