-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
gh-114828: parenthesize non-atomic macro definitions in pycore_symtable.h #115143
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
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.
Thanks for figuring this out!
It might be worth backporting this to 3.11, though there will be some conflicts and it's unlikely that we'll make a lot of changes to the 3.11 symtable at this point. Up to you. |
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.
Thanks!
Hmm. I think my (weak) inclination is not to backport to 3.11, given that AFAIK there were major symtable changes in 3.12 but not in 3.11, so it seems unlikely we'll be backporting many changes to 3.11, and even less likely that any such changes would be affected by this. This PR is actually a bugfix for 3.12 (given that my But like I say, this is a weak preference, and I'll happily backport to 3.11 if anyone feels strongly that that's the thing to do. |
Thanks @carljm for the PR 🌮🎉.. I'm working now to backport this PR to: 3.12. |
…symtable.h (pythonGH-115143) (cherry picked from commit 8f0998e) Co-authored-by: Carl Meyer <[email protected]>
GH-115149 is a backport of this pull request to the 3.12 branch. |
In #115139, I used the expression
~DEF_FREE
as a mask to clear theDEF_FREE
bit in a symbol table entry.Unfortunately,
DEF_FREE
is defined as#define DEF_FREE 2<<4
, so this macro-expands to~2<<4
, and the bitwise negation binds more tightly than the bit-shift, so this actually meant(~2)<<4
rather than the~(2<<4)
which I intended.This is why non-atomic macro bodies should always be parenthesized!
Fix it by parenthesizing all the non-atomic definitions in
pycore_symtable.h
, which not only fixes my~DEF_FREE
, but also prevents anyone else making the same mistake in future.