-
Notifications
You must be signed in to change notification settings - Fork 7
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
[class.bit] p2 The wording about the affect of unnamed bit-field with a width zero is unclear #650
Comments
If you believe "allocation unit boundary" is not defined, why is "allocation unit" any better? And why do you believe the C wording of an undefined "unit" is anywhere near good? |
Hmmm, "allocation unit" is another unclear part. This wording just tries to state the effect of unnamed bit-field with a width of zero, that the next bit-field is packed into a new X, and the X is something that needs further definition. |
I think "aligned at an allocation unit boundary" is synonymous with "not packed into the same unit as the previous one". And, of course, what's the net effect of this rule, anyway, in terms of the abstract machine? None, it feels. The definition of "memory location" already takes care of unnamed bit-fields separately. |
How are they associated? Is there any extra meaning to allocation unit boundary? Using packed might be closer to that meaning. Like the first paragraph phrase that
The corresponding wording could be
The remaining thing is to clarify what the allocation unit boundary means. Specifically, the boundary might mean a new unit. |
"boundary" means "border". It seems clear from the context that an allocation unit cannot span such a boundary. |
The sentence seemingly misuses the term "alignment". Would it be better to say "a maximal sequence of adjacent bit-fields all having nonzero width are packed into adjacent bytes; an unnamed bit-field with a width of zero specifies the next bit-field, if any, is not packed into previous bytes"? |
The "alignment" used here certainly is unrelated to the alignment specified in [basic.align]. |
While revising this wording, it may be helpful to have a note that the type of the zero-width bit-field can affect layout compatibility. It may also be helpful to note that the presence of a zero-width bit-field can affect layout compatibility even if the next non-static data member is not a bit-field. Additionally, depending on what wording we use, we might want to say "any immediately following bit-field" instead of "next bit-field". |
This is also the issue here: the "alignment" is not that alignment in [basic.align], which makes the whole wording confusing. It is hard to know what the sentence intends to mean. |
Full name of submitter (unless configured in github; will be published with the issue): Jim X
[class.bit] p2 says:
The intent expressed by this wording is unclear. The wording allocation unit boundary is not defined, as well as allocation unit. The C standard has the following wording:
For this code:
GCC and Clang have this layout for
S1
whereas in msvc
In any implementation, the unnamed bit-field with a width of zero just has the same effect that places the next bit-field in a new unit.
Suggested Resolution
The intent is not clearly expressed by the current wording. The proposed wording might be:
The text was updated successfully, but these errors were encountered: