Mark Dickinson <dicki...@gmail.com> added the comment:

> I think the patch is *NOT* correct.

Can you elaborate?  It works fine for that example on a 64-bit build;  not sure 
why 32-bit would be any different.

The idea is just that the single cast forces the addition to be done as an 
addition of integers of type size_t.  Since the integers being added are (a) 
nonnegative and (b) both fit into a Py_ssize_t, the sum fits into a size_t 
without overflow, and the result of dividing the sum by 2 fits into a size_t.

(This is all assuming that 2*Py_SSIZE_T_MAX fits into a size_t, but that's a 
fairly safe assumption in practice.)

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue13496>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to