-
-
Notifications
You must be signed in to change notification settings - Fork 33.9k
bpo-35959: Rework integer overflow path in math.prod and add more tests #11809
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
4a30482 to
5025c0d
Compare
2e18189 to
933fb66
Compare
|
@mdickinson Do you have some suggestions for extra checks to cover these corner cases? |
eamanu
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. I am testing the PR on Unbuntu 18 04 x86_64 and run ok.
|
@mdickinson At the end I have used Python2's approach for overflow handling. Could you review again this PR? |
Will do, but I'm not going to have time before the weekend. If another core dev wants to review before then, that's fine with me. |
|
I am going to merge this one as this is a known problem and I do not want to miss more alphas. As the code used is the code of how Python2 managed overflow for multiplication and this is battle tested, this should be more than ok. In case we want to improve/speedup how we handle the overflow we can do it in another PR. |
The overflow check was relying on undefined behaviour as it was using the result of the multiplication to do the check, and once the overflow has already happened, any operation on the result is undefined behaviour.
I have moved the test to the correct class as well (TestMath).
https://bugs.python.org/issue35959