-
Notifications
You must be signed in to change notification settings - Fork 295
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
Implement struct bitfield layout rules according to GCC #1926
base: main
Are you sure you want to change the base?
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, |
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).