]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
Fix the internals of our hash functions to used unsigned values during hash
authorGregory P. Smith <greg@krypto.org>
Tue, 11 Dec 2012 02:32:53 +0000 (18:32 -0800)
committerGregory P. Smith <greg@krypto.org>
Tue, 11 Dec 2012 02:32:53 +0000 (18:32 -0800)
commitc2176e46d797c8aea60cdcd2ddf44f6bb88394b4
tree5c4d898d216d25af779db557da42e1fccbb31e6d
parentc0dd80e439bff4bd7cd9acc34ae023b4e8adf4aa
parent27cbcd6241d787b5e99c6ed05ec8377051f397aa
Fix the internals of our hash functions to used unsigned values during hash
computation as the overflow behavior of signed integers is undefined.

NOTE: This change is smaller compared to 3.2 as much of this cleanup had
already been done.  I added the comment that my change in 3.2 added so that the
code would match up.  Otherwise this just adds or synchronizes appropriate UL
designations on some constants to be pedantic.

In practice we require compiling everything with -fwrapv which forces overflow
to be defined as twos compliment but this keeps the code cleaner for checkers
or in the case where someone has compiled it without -fwrapv or their
compiler's equivalent.

Found by Clang trunk's Undefined Behavior Sanitizer (UBSan).

Cleanup only - no functionality or hash values change.
Include/pyport.h
Objects/setobject.c
Objects/tupleobject.c
Objects/unicodeobject.c