BlockPo / BlockPo-to-Tradelayer

Incubation Repo for the TradeLayer protocol, 0.2.0
http://www.tradelayer.org
Other
8 stars 8 forks source link

Prevent UB when computing abs value for num opcode serialize #322

Closed philmb3487 closed 4 years ago

philmb3487 commented 4 years ago

However this is undefined behaviour under certain circumstances: https://stackoverflow.com/questions/17313579/is-there-a-safe-way-to-get-the-unsigned-absolute-value->

A relevant example can be found at : https://godbolt.org/z/yRwtCG

This was first reported in: bitcoin/bitcoin#18046

santos177 commented 4 years ago

utACK. It looks clean using static casts, thanks for that!