Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32.1k
gh-96821: Fix undefined behaviour inaudioop.c
#96923
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
gh-96821: Fix undefined behaviour inaudioop.c
#96923
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Left-shifting negative numbers is undefined behaviour.Fortunately, multiplication works just as well, is defined behaviour,and gets compiled to the same machine code as before by optimizingcompilers.
matthiasgoergens commentedSep 19, 2022 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@kumaraditya303@mdickinson@erlend-aasland Would you please have a look? Thanks! |
kumaraditya303 commentedSep 26, 2022 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Sorry but I won't have time for this in the near future, Mark or Erlend can take a look. |
Uh oh!
There was an error while loading.Please reload this page.
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.
The changes LGTM at least in principle; I haven't done much in the way of testing.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
@matthiasgoergens Can we revert the changes at lines 173 and 262 of the original code? I'm fairly sure that those changes aren't necessary, because the quantity being shifted is always nonnegative. |
To be clear, I'm happy with the rest of the changes as-is, so if@JelleZijlstra is also happy, I think we can merge after those two reversions. |
@mdickinson Thanks. I'll revert the lines you asked about. |
matthiasgoergens commentedOct 9, 2022 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@mdickinson@JelleZijlstra I applied the suggested changes. Thanks for having a look! |
*pythongh-96821: Fix undefined behaviour in `audioop.c`Left-shifting negative numbers is undefined behaviour.Fortunately, multiplication works just as well, is defined behaviour,and gets compiled to the same machine code as before by optimizingcompilers.Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Uh oh!
There was an error while loading.Please reload this page.
Left-shifting negative numbers is undefined behaviour.
Fortunately, multiplication works just as well, is (implementation) defined behaviour, and gets compiled to the same machine code as before by optimizing compilers.
-fstrict-overflow
#96821