Is using unsigned integer overflow good practice?

后端 未结 12 546
耶瑟儿~
耶瑟儿~ 2020-12-01 15:55

I was reading the C Standard the other day, and noticed that unlike signed integer overflow (which is undefined), unsigned integer overflow is well defined. I\'ve seen it us

12条回答
  •  没有蜡笔的小新
    2020-12-01 16:37

    One way where I could think of unsigned integer overflow causing a problem is when subtracting from a small unsigned value, resulting in it wrapping to a large positive value.

    Practical advice for integer overflows:
    http://www.gnu.org/software/hello/manual/autoconf/Integer-Overflow-Basics.html#Integer-Overflow-Basics

提交回复
热议问题