Where in the C99 standard does it say that signed integer overflow is undefined behavior?

后端 未结 1 1713
渐次进展
渐次进展 2020-12-19 19:45

Where in the C99 standard does it say that signed integer overflow is undefined behavior?

I see the comment about unsigned integer overflow being well-defined (see W

相关标签:
1条回答
  • 2020-12-19 20:07

    I don't have a copy of C99, but in the C11 standard this text appears in Section 6.5, paragraph 5:

    If an exceptional condition occurs during the evaluation of an expression (that is, if the result is not mathematically defined or not in the range of representable values for its type), the behavior is undefined.

    Which would seem to be a catch-all for any overflow; the text about unsigned integers then becomes a special-case above 6.5 ¶ 5.

    0 讨论(0)
提交回复
热议问题