bpo-35091: Objects/listobject.c: Don't rely on signed int overflow in… by izbyshev · Pull Request #10175 · python/cpython
Conversation
… gallop functions Signed integer overflow is undefined behavior.
Other option is using unsigned integers. In this case additional checks could be removed. The check in the while condition would be enough.
@serhiy-storchaka If it's OK to change types of several variables in affected functions (because if only ofs is changed, we'd need to add casts all over the place to avoid signed/unsigned comparison warnings), I'll update the patch.
Added @tim-one, the author of this code.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters