Skip to content
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

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

Open
yurivict opened this issue Jan 12, 2019 · 1 comment

Comments

@yurivict
Copy link

./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;
          ^
@Vsevolod-Livinskij
Copy link
Contributor

Vsevolod-Livinskij commented Jan 15, 2019

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants