https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128751

Uroš Bizjak <ubizjak at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |liuhongt at gcc dot gnu.org

--- Comment #3 from Uroš Bizjak <ubizjak at gmail dot com> ---
What x86_64 psABI does say (all in section 3.1.2, “Bit-Fields”, and section
3.2.3):

* Alignment (section 3.1.2, p. 20): “Unnamed bit-fields’ types do not affect
the alignment of a structure or union.” This is the only sentence in the
document that mentions unnamed bit-fields.
* Zero-width (footnote 18 on p. 25, attached to classification step 4):
“Zero-width bit-fields are NO_CLASS.”
* NO_CLASS definition (section 3.2.3): “This class is used as initializer in
the algorithms. It will be used for padding and empty structures and unions.”
* Bit-fields in general (section 3.1.2): they “obey the same size and alignment
rules as other structure and union members”, and are allocated from right to
left within a storage unit of their declared type.

What it doesn’t say:

* Nothing about how non-zero-width unnamed bit-fields are classified. The word
“unnamed” appears only in the alignment sentence above.
* Step 4 of the classification algorithm says “each field of an object is
classified recursively”, with no exception for unnamed fields apart from the
zero-width footnote.
* “Padding” is never defined. In section 3.1.2 it is only mentioned as
something objects can need to meet size and alignment constraints, whose
contents are undefined.
* “Empty structures and unions” is not defined either.

GCC’s reading (INTEGER) follows from step 4 read literally. An unnamed
bit-field is a field, and only zero-width ones are carved out. The footnote’s
explicit carve-out for zero-width bit-fields is mild evidence that unnamed
non-zero-width ones were not meant to be excluded.

The alignment sentence shows the authors thought about unnamed bit-fields and
chose to exempt them from one property only. They did not add an equivalent
exemption for classification.

Reply via email to