-
Notifications
You must be signed in to change notification settings - Fork 298
Implement struct bitfield layout rules according to GCC #1926
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
Just a quick note, looks like 3.14 has some fixes for the bit fields:
After some quick tests it seems to match up with your |
Thanks for the pointer. I am updating the tests to verify the 3.14 behaviour. For what I can see:
|
I've been reading CPython's Anyway, |
Thanks! |
@slozier I've notice that I merged this branch rather than squashed. There is only one commit on top of it, so I could force-push a correction to rectify things. Shall we? |
@BCSharp Sure if you feel like it. I don't mind either way. I can't recall if I added branch protections that would prevent a force push (I know github was bugging me about it for a while). |
Yes, I prefer merge commits reserved for complex, sprawling changes where it is useful to preserve history to understand what is happening, not for small changes like this one. And yes, the branch is force-push protected. I can't find out how to disable it or maybe only the owner can do it. So I'd appreciate if you disable it temporarily; I have the commits ready to be pushed. |
You can exclude certain people from branch protection rules |
Ok, I found the setting and disabled it. |
Done. |
This new layout rules only apply on POSIX. The rules for Clang are the same as for GCC (but different than the MSVC rules used by IronPython so far). On a few occasions, CPython produces different results, which frankly don't make sense to me and look like a bug in CPython: extra unnecessary padding bits, bitfield container unit not properly aligned, or even storage bits of two bitfields overlapping — the last case signals that there is a serious problem with the CPython's layout rules. More importantly, the layout that CPython produces is not the same as GCC/Clang's. In case of such a discrepancy, IronPython follows GCC, not CPython. After all, the purpose of
ctypes
is interoperability with C not CPython. To see the problematic cases, scan added tests for comment # bug in CPython.What is still not supported:
_pack_
with bifields — requires more investigation of what the actual rules areOn the bright side, since CPython doesn't support (or supports incorrectly) some of the cases, it just tells me that those problematic scenarios are not commonly being used in the wild (or they would have been reported to the CPython community already).