-
Notifications
You must be signed in to change notification settings - Fork 80
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
Bitfields support #955
Comments
When I wrote this ticket I had assumed that the size of the memory address was dependent upon the first entries type, this isn't the case. It is whatever number of bytes it fits inside of at a minimum that is guaranteed. But from a practical standpoint, we can use a power of 2 up to a pointer in size to assume what it'll be. With a default of 8 bytes (since all CPU's today are 64bit). It'll also need to take into account alignment and that'll drop the previous value down to the minimum number of bytes. Oh how I hate the need for this mitigation. |
Anddd we are back at not negatable. struct Foo {
unsigned short x;
unsigned int a : 12;
unsigned int b : 12;
unsigned int c : 8;
//void* next;
};
int main() {
struct Foo foo;
foo.a = 1;
foo.b = 0;
return 0;
} |
No wait, if you chuck it into an anonymous struct it's fine. struct Foo {
unsigned short x;
struct {
unsigned int a : 12;
unsigned int b : 12;
unsigned int c : 8;
};
//void* next;
}; sigh |
With the upcoming bitfields feature to D, we've been trying to understand Walter's position on why he will not accept it to have a predictable layout.
Our conclusion has been that as long as you do not start a bit field in one memory location and end in another it is predictable regardless of the types used.
So what dscanner will need to warn for the following code:
From C23 specification:
The text was updated successfully, but these errors were encountered: