Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Get rid of integer overflow in copy_move_algo.hpp (-fsanitize=integer). #109
When running a program with -fsanitize=integer, I get runtime errors on line 514 of copy_move_algo.hpp due to the way the while loop is written:
[...] boost/container/detail/copy_move_algo.hpp:514:15: runtime error: unsigned integer overflow: 0 - 1 cannot be represented in type 'typename boost::container::allocator_traits<new_allocator<pair<unsigned int, __normal_iterator<const unsigned int *, vector<unsigned int, allocator > > > > >::size_type' (aka 'unsigned long')
When the loop terminates, n-- will cause unsigned integer overflow in n. Although the value of n is discarded otherwise, this behavior is likely unwanted and unintentional, thus I'm submitting this PR.