Is &errno legal C?

后端 未结 5 990
南方客
南方客 2020-12-23 19:43

Per 7.5,

[errno] expands to a modifiable lvalue175) that has type int, the value of which is set to a positive error number by several library functio

5条回答
  •  渐次进展
    2020-12-23 20:00

    We can find a counterexample: because a bit-field could have type int, errno can be a bit-field. In that case, &errno would be invalid. The behavior of standard is here to do not explicitly say you can write &errno, so the definition of the undefined behavior applies here.

    C11 (n1570), § 4. Conformance
    Undefined behavior is otherwise indicated in this International Standard by the words ‘‘undefined behavior’’ or by the omission of any explicit definition of behavior.

提交回复
热议问题