boostorg / container

STL-like containers from Boost
http://www.boost.org/libs/container/
Boost Software License 1.0
101 stars 113 forks source link

Fix integer rollover that triggers clang ubsan when U is unsigned #51

Closed garyfurnish closed 7 years ago

garyfurnish commented 7 years ago

If U is unsigned in destroy_alloc_n, n-- can lead to unsigned integer rollover when n is 0. This behavior, while trivial and defined, is sufficient to trigger clang's ubsan detector and create excess noise.

/mnt/fscratch0/pub/dependencies/boost/boost/container/detail/copy_move_algo.hpp:966:11: runtime error: unsigned integer overflow: 0 - 1 cannot be represented in type 'unsigned long'

igaztanaga commented 7 years ago

Thanks for the patch. Added to develop branch, will merge in time for Boost 1.65