This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author skrah
Recipients ezio.melotti, georg.brandl, lemburg, skrah
Date 2011-02-10.19:25:16
SpamBayes Score 1.446046e-07
Marked as misclassified No
Message-id <20110210192449.GA5470@sleipnir.bytereef.org>
In-reply-to <1297330831.08.0.0747559116298.issue11167@psf.upfronthosting.co.za>
Content
Marc-Andre Lemburg <report@bugs.python.org> wrote:
> 
> Marc-Andre Lemburg <mal@egenix.com> added the comment:
> 
> Could you try the same in Python 2.7 ?

It's the same, just in stringobject.c. Many hash functions have this issue.

> The overflow is intended (after all, it's a hash function), but we should
> probably add a cast to Py_hash_t to the hash building line in order to make
> the compiler aware of this.

I think I'd just do the hash calculation in unsigned and cast at the end
of the function. For the conversion from unsigned to signed we'd still
rely on implementation defined behavior [1], but at least the signed
integer overflow would be gone.

[1] Mark Dickinson made an effort to document assumptions for unsigned
to signed conversions. I don't know if this has found its way it into
the developer docs:

http://mail.python.org/pipermail/python-dev/2009-December/094388.html
History
Date User Action Args
2011-02-10 19:25:17skrahsetrecipients: + skrah, lemburg, georg.brandl, ezio.melotti
2011-02-10 19:25:16skrahlinkissue11167 messages
2011-02-10 19:25:16skrahcreate