Message152400
> 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.) |
|
Date |
User |
Action |
Args |
2012-01-31 17:50:57 | mark.dickinson | set | recipients:
+ mark.dickinson, tim.peters, rhettinger, jcea, amaury.forgeotdarc, pitrou, akira, Voo |
2012-01-31 17:50:57 | mark.dickinson | set | messageid: <1328032257.57.0.46607816978.issue13496@psf.upfronthosting.co.za> |
2012-01-31 17:50:57 | mark.dickinson | link | issue13496 messages |
2012-01-31 17:50:56 | mark.dickinson | create | |
|