Skip to content

clang complains about generated programs: width of bit-field 'member_1_0' (29 bits) exceeds the width of its type #74

Open

Description

@yurivict
./init.h:224:17: warning: width of bit-field 'member_1_0' (29 bits) exceeds the width of its type; value will be truncated to 8 bits [-Wbitfield-width]
    signed char member_1_0 : 29;
                ^
./init.h:228:11: warning: width of bit-field 'member_1_2' (20 bits) exceeds the width of its type; value will be truncated to 16 bits [-Wbitfield-width]
    short member_1_2 : 20;
          ^

Activity

  1. Vsevolod-Livinskij commented on Jan 15, 2019

    @Vsevolod-Livinskij
    Contributor

    This is intended behavior. It is not an issue, because C++ standard states that “The value of the integral constant expression may be larger than the number of bits in the object
    representation (6.7) of the bit-field’s type; in such cases the extra bits are padding bits (6.7).” (12.2.4).

    If you want, you can change the maximal size of bit-field in this line. But be aware that GCC and LLVM treat operations differently on bit-fields that are wider than int (see pr).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions